You are here: Home / Topics / Search / java interview questions
Showing 39 Search Results for : java interview questions

What are the FileInputStream and FileOutputStream?

Filed under: Java Interview Questions on 2024-10-25 15:45:14
FileInputStream and FileOutputStream are two fundamental classes in Java used for reading from and writing to files, respectively. They are part of the Java I/O (Input/Output) package and operate on byte streams, making them suitable for handling binary data.FileInputStreamPurpose: FileInputStream i

Why do we need abstract classes in java?

Filed under: Java Interview Questions on 2024-10-25 15:42:27
Abstract classes in Java serve several important purposes in object-oriented programming. Here are the key reasons why we use abstract classes:1. Defining a Base ClassAbstract classes provide a way to define a common base class for related subclasses. They can encapsulate shared behavior and attribu

What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class hierarchy?

Filed under: Java Interview Questions on 2024-10-25 15:38:46
The Reader/Writer and InputStream/OutputStream class hierarchies in Java are both designed for handling input and output operations, but they serve different purposes and work with different types of data. Here’s a detailed comparison:1. Data TypeInputStream/OutputStream: These classes are designe

What do you understand by an IO stream in Java?

Filed under: Java Interview Questions on 2024-10-25 15:35:36
Java brings various Streams with its I/O package that helps the user to perform all the input-output operations. These streams support all types of objects, data types, characters, files, etc to fully execute the I/O operations.An I/O (Input/Output) stream in Java is a sequence of data that flows in

What is a static variable in Java?

Filed under: Java Interview Questions on 2024-10-25 15:30:19
A static variable in Java is a variable that is declared with the static keyword within a class. It is also known as a class variable. Here are the key characteristics and features of static variables:Key CharacteristicsShared Across All Instances: A static variable is shared among all instances (ob

What is a Class Variable?

Filed under: Java Interview Questions on 2024-10-25 15:25:09
A class variable in Java is a variable that is declared with the static keyword within a class. It is also known as a static variable. Here are some key characteristics and features of class variables:Key CharacteristicsShared Across All Instances: Class variables are shared among all instances (obj

Why do we need wrapper classes?

Filed under: Java Interview Questions on 2024-10-25 14:39:58
Wrapper classes in Java are used for several important reasons:Object Representation: Java is primarily an object-oriented programming language, and wrapper classes allow primitive data types (like int, char, double, etc.) to be treated as objects. This is necessary when you need to work with collec

Can we declare Pointer in Java?

Filed under: Java Interview Questions on 2024-10-25 14:36:45
In Java, you can't explicitly declare pointers like you do in languages such as C or C++. However, Java uses references, which are somewhat similar to pointers in that they refer to the memory location of an object.Here's a quick breakdown:References: When you create an object in Java, you use a ref

Explain different data types in Java.

Filed under: Java Interview Questions on 2024-10-25 14:32:31
There are 2 types of data types in Java as mentioned below:Primitive Data TypeNon-Primitive Data Type or Object Data typePrimitive Data Type: Primitive data are single values with no special capabilities. There are 8 primitive data types:boolean: stores value true or falsebyte: stores an 8-bit signe

What is Java String Pool?

Filed under: Java Interview Questions on 2024-10-25 14:29:27
A Java String Pool is a place in heap memory where all the strings defined in the program are stored. A separate place in a stack is there where the variable storing the string is stored. Whenever we create a new string object, JVM checks for the presence of the object in the String pool, If String 

What is the difference between JVM, JRE, and JDK.

Filed under: Java Interview Questions on 2024-10-25 14:24:07
JVM: JVM also known as Java Virtual Machine is a part of JRE. JVM is a type of interpreter responsible for converting bytecode into machine-readable code. JVM itself is platform dependent but it interprets the bytecode which is the platform-independent reason why Java is platform-independent. J

What is a classloader? Java Interview Question

Filed under: Java Interview Questions on 2024-10-25 14:17:08
Classloader is the part of JRE(Java Runtime Environment), during the execution of the bytecode or created .class file classloader is responsible for dynamically loading the java classes and interfaces to JVM(Java Virtual Machine). Because of classloaders Java run time system does not need to know ab

What are Memory storages available with JVM?

Filed under: Java Interview Questions on 2024-10-25 06:55:36
JVM consists of a few memory storages as mentioned below:JVM consists of a few memory storages as mentioned below:Class(Method) Area: stores class-level data of every class such as the runtime constant pool, field, and method data, and the code for methods.Heap: Objects are created or objects are st

What is JIT in Java?

Filed under: Java Interview Questions on 2024-10-25 06:53:17
JIT stands for (Just-in-Time) compiler is a part of JRE(Java Runtime Environment), it is used for better performance of the Java applications during run-time. The use of JIT is mentioned in step by step process mentioned below:Source code is compiled with javac to form bytecodeBytecode is further pa

What is JVM?

Filed under: Java Interview Questions on 2024-10-25 06:51:47
JVM stands for Java Virtual Machine it is a Java interpreter. It is responsible for loading, verifying, and executing the bytecode created in Java.Although it is platform dependent which means the software of JVM is different for different Operating Systems it plays a vital role in making Java platf

What are the top Java Features?

Filed under: Java Interview Questions on 2024-10-25 06:50:44
Java is one the most famous and most used language in the real world, there are many features in Java that makes it better than any other language some of them are mentioned below:Simple: Java is quite simple to understand and the syntax Platform Independent: Java is platform independent means 

Is Java Platform Independent if yes then how?

Filed under: Java Interview Questions on 2024-10-25 06:37:13
Yes, Java is a Platform Independent language. Unlike many programming languages javac compiles the program to form a bytecode or .class file. This file is independent of the software or hardware running but needs a JVM(Java Virtual Machine) file preinstalled in the operating system for further execu

What do you understand by classes in java?

Filed under: JAVA Interview Questions on 2022-07-02 16:09:45
In Java, a class is a user-defined data type from which objects are created. It can also be called as a blueprint or prototype. A class is a collection of various methods and variables which represent a set of properties that are common to all the objects of one type. A class includes components suc

What do you mean by an object in java?

Filed under: JAVA Interview Questions on 2022-07-02 16:09:28
An object is a basic entity in an object-oriented programming language that represents the real-life entities. Many objects are created by a java program that interacts with the invoking methods. The state of an object is represented by its attributes and reflects its properties. The behavior of an 

Compare java and python.

Filed under: JAVA Interview Questions on 2022-07-02 16:09:13
Java and Python, both the languages hold an important place in today’s IT industry. But in some factors, one is better than the other. Such factors are:Java is easy to use, whereas Python is very good in this case.The speed of coding in Java is average, whereas in Python it is excellent.In Java, t

Outline the major features of Java.

Filed under: JAVA Interview Questions on 2022-07-02 16:08:52
The major features of Java are listed below: –Object-oriented: – Java language is based on object-oriented programming. In this, the class and the methods describe the state and behavior of an object. The programming is done by relating a problem with the real world object.Portable: – the conv

Looping in JAVA and Types of Loops in JAVA

Filed under: JAVA Interview Questions on 2022-07-02 16:08:18
If we want to execute a statement or a block of statements repeatedly in java, then loops are used. And such a process is known as looping. There are basically 3 types of looping. They are: –"For loop": – for executing a statement or a set of statements for a given number of times, for loops are

What are the various access specifiers in Java?

Filed under: JAVA Interview Questions on 2022-07-02 16:07:16
Access specifiers in java are the keywords which define the access scope of the function. It can be used before a class or a method. There are basically 4 types of access specifiers in java: –Public: – class, methods, and fields are accessible from anywhere.Protected: – methods and fields are 

What is the difference between JDK, JRE, and JVM?

Filed under: JAVA Interview Questions on 2022-07-02 16:06:54
It is important to understand the difference between JDK, JRE, and JVM in Java.JVM (Java Virtual Machine):  Java virtual machine is actually an abstract machine which provides a runtime environment in which the java bytecode gets executed. A JVM performs some main tasks such as- loading, verify

What is the need of the JAVA?

Filed under: JAVA Interview Questions on 2022-07-02 16:05:12
The need of Java is that it enforces an object-oriented programming model and can be used to create complete applications that can run on a single computer or be distributed across servers and clients in a network thus it can easily build mobile applications or run on desktop applications that use d