GFG Java Questions and Answers
GFG Java Questions and Answers
GFG Java Questions and Answers
Java Arrays Java Strings Java OOPs Java Collection Java 8 Tutorial Java Multithreading Java Exceptio
In this article, we will provide 200+ Core Java Interview Questions tailored
for both freshers and experienced professionals with 3, 5, and 8 years of
experience. Here, we cover everything, including core Java concepts, Object-
Oriented Programming (OOP), multithreading, exception handling, design
patterns, Java Collections, and more, that will surely help you to crack Java
interviews. Along with these interview questions you can also try Java
course to enhance your Java concepts.
Table of Content
Java Interview questions for Freshers
Java Intermediate Interview Questions
Java Interview Questions For Experienced
Java Difference Interview Questions
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:
3. What is JVM?
https://www.geeksforgeeks.org/java-interview-questions/ 2/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
4. What is JIT?
https://www.geeksforgeeks.org/java-interview-questions/ 3/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
3. JIT is a part of JVM, JIT is responsible for compiling bytecode into native
machine code at run time.
4. The JIT compiler is enabled throughout, while it gets activated when a
method is invoked. For a compiled method, the JVM directly calls the
compiled code, instead of interpreting it.
5. As JVM calls the compiled code that increases the performance and
speed of the execution.
6. What is a classloader?
https://www.geeksforgeeks.org/java-interview-questions/ 4/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
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.
JDK: JDK stands for Java Development Kit which provides the environment
to develop and execute Java programs. JDK is a package that includes two
things Development Tools to provide an environment to develop your Java
programs and, JRE to execute Java programs or applications.
To know more about the topic refer to the Differences between JVM, JRE,
and JDK.
https://www.geeksforgeeks.org/java-interview-questions/ 5/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
https://www.geeksforgeeks.org/java-interview-questions/ 6/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
1. public: the public is the access modifier responsible for mentioning who
can access the element or the method and what is the limit. It is
responsible for making the main function globally available. It is made
public so that JVM can invoke it from outside the class as it is not present
in the current class.
2. static: static is a keyword used so that we can use the element without
initiating the class so to avoid the unnecessary allocation of the memory.
3. void: void is a keyword and is used to specify that a method doesn’t
return anything. As the main function doesn’t return anything we use
void.
4. main: main represents that the function declared is the main function. It
helps JVM to identify that the declared function is the main function.
5. String args[]: It stores Java command-line arguments and is an array of
type java.lang.String class.
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
is available in the pool, the same object reference is shared with the
variable, else a new object is created.
https://www.geeksforgeeks.org/java-interview-questions/ 7/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
Example:
String str1="Hello";
// "Hello" will be stored in String Pool
// str1 will be stored in stack memory
11. What will happen if we declare don’t declare the main as static?
We can declare the main method without using static and without getting
any errors. But, the main method will not be treated as the entry point to the
application or the program.
https://www.geeksforgeeks.org/java-interview-questions/ 8/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
We can also have the hidden classes that are not visible outside and are
used by the package.
It is easier to locate the related classes.
User-defined packages
Build In packages
Primitive Data Type: Primitive data are single values with no special
capabilities. There are 8 primitive data types:
Strings
Array
Class
Object
Interface
https://www.geeksforgeeks.org/java-interview-questions/ 9/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
No, Java doesn’t provide the support of Pointer. As Java needed to be more
secure because which feature of the pointer is not provided in Java.
20. What is the default value of float and double datatype in Java?
The default value of the float is 0.0f and of double is 0.0d in Java.
The primitive data types are the ones from which further data types could be
created. For example, integers can further lead to the construction of long,
byte, short, etc. On the other hand, the string cannot, hence it is not
primitive.
Getting back to the wrapper class, Java contains 8 wrapper classes. They are
Boolean, Byte, Short, Integer, Character, Long, Float, and Double. Further,
custom wrapper classes can also be created in Java which is similar to the
concept of Structure in the C programming language. We create our own
wrapper class with the required data types.
The wrapper class is an object class that encapsulates the primitive data
types, and we need them for the following reasons:
https://www.geeksforgeeks.org/java-interview-questions/ 10/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
It can be used throughout the class. The scope is limited to the method.
24. What are the default values assigned to variables and instances in
Java?
In Java When we haven’t initialized the instance variables then the compiler
initializes them with default values. The default values for instances and
variables depend on their data types. Some common types of default data
types are:
The default value for numeric types (byte, short, int, long, float, and
double) is 0.
The default value for the boolean type is false.
The default value for object types (classes, interfaces, and arrays) is null.
The null character, “u0000, ” is the default value for the char type.
Example:
Java
Output:
byte value0
short value0
int value0
long value0
boolean valuefalse
char value
float value0.0
double value0.0
string valuenull
object valuenull
Array valuenull
https://www.geeksforgeeks.org/java-interview-questions/ 12/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
Example:
Java
Output
There is no default value stored with local variables. Also, primitive variables
and objects don’t have any default values.
27. Explain the difference between instance variable and a class variable.
Example:
Java
https://www.geeksforgeeks.org/java-interview-questions/ 13/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
Output
Name John
Example:
Java
Output
https://www.geeksforgeeks.org/java-interview-questions/ 14/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
The static keyword is used to share the same variable or method of a given
class. Static variables are the variables that once declared then a single copy
of the variable is created and shared among all objects at the class level.
Example:
Java
Example:
Java
Output:
Although, System.err have many similarities both of them have quite a lot of
difference also, let us check them.
System.out System.err
Example:
Java
https://www.geeksforgeeks.org/java-interview-questions/ 16/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
// Scanner class with System.in
Scanner sc = new Scanner(System.in);
// Taking input from the user
int x = sc.nextInt();
int y = sc.nextInt();
// Printing the output
System.out.printf("Addition: %d", x + y);
}
}
Output:
3
4
Addition: 7
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.
31. What is the difference between the Reader/Writer class hierarchy and
the InputStream/OutputStream class hierarchy?
The key difference between them is that byte stream data is read and
written by input/output stream classes. Characters are handled by the
Reader and Writer classes. In contrast to Reader/Writer classes, which
accept character arrays as parameters, input/output stream class methods
accept byte arrays. In comparison to input/output streams, the Reader/Writer
classes are more efficient, handle all Unicode characters, and are useful for
internalization. Use Reader/Writer classes instead of binary data, such as
pictures, unless you do so.
Example:
Java
https://www.geeksforgeeks.org/java-interview-questions/ 17/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
class GFG {
public static void main(String[] args) {
try {
// Writing binary data to a file using OutputStream
byte[] data = {(byte) 0xe0, 0x4f, (byte) 0xd0, 0x20, (byte)
0xea};
OutputStream os = new FileOutputStream("data.bin");
os.write(data);
os.close();
is.read(newData);
is.close();
Output
32. What are the super most classes for all the streams?
All the stream classes can be divided into two types of classes that are
ByteStream classes and CharacterStream Classes. The ByteStream classes
are further divided into InputStream classes and OutputStream classes.
CharacterStream classes are also divided into Reader classes and Writer
classes. The SuperMost classes for all the InputStream classes is
java.io.InputStream and for all the output stream classes is
java.io.OutPutStream. Similarly, for all the reader classes, the super-most
class is java.io.Reader, and for all the writer classes, it is java.io.Writer.
https://www.geeksforgeeks.org/java-interview-questions/ 18/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
To read and write data, Java offers I/O Streams. A Stream represents an
input source or an output destination, which could be a file, an i/o device,
another program, etc. FileInputStream in Java is used to read data from a
file as a stream of bytes. It is mostly used for reading binary data such as
images, audio files, or serialized objects.
Example:
Example:
When we are working with the files or stream then to increase the
Input/Output performance of the program we need to use the
BufferedInputStream and BufferedOutputStream classes. These both
classes provide the capability of buffering which means that the data will be
stored in a buffer before writing to a file or reading it from a stream. It also
reduces the number of times our OS needs to interact with the network or
the disk. Buffering allows programs to write a big amount of data instead of
writing it in small chunks. This also reduces the overhead of accessing the
network or the disk.
BufferedInputStream(InputStream inp);
// used to create the bufferinput stream and save the arguments.
BufferedOutputStream(OutputStream output);
// used to create a new buffer with the default size.
https://www.geeksforgeeks.org/java-interview-questions/ 19/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
Example:
An I/O filter also defined as an Input Output filter is an object that reads
from one stream and writes data to input and output sources. It used java.io
package to use this filter.
37. How many ways you can take input from the console?
There are two methods to take input from the console in Java mentioned
below:
Example:
Java
https://www.geeksforgeeks.org/java-interview-questions/ 20/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
// the command line arguments
for (String val : args)
System.out.println(val);
}
else
System.out.println("No command line "
+ "arguments found.");
}
}
// Use below commands to run the code
// javac GFG.java
// java Main GeeksforGeeks
Java
Output
null
Java
https://www.geeksforgeeks.org/java-interview-questions/ 21/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
Java
Output:
GeeksforGeeks
print, println, and printf all are used for printing the elements but print prints
all the elements and the cursor remains in the same line. println shifts the
cursor to next line. And with printf we can use format identifiers too.
Operators are the special types of symbols used for performing some
operations over variables and values.
https://www.geeksforgeeks.org/java-interview-questions/ 22/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
1. Arithmetic Operators
2. Unary Operators
3. Assignment Operator
4. Relational Operators
5. Logical Operators
6. Ternary Operator
7. Bitwise Operators
8. Shift Operators
9. instance of operator
Operators like >> and >>> seem to be the same but act a bit differently. >>
operator shifts the sign bits and the >>> operator is used in shifting out the
zero-filled bits.
Example:
Java
import java.io.*;
// Driver
class GFG {
public static void main(String[] args) {
int a = -16, b = 1;
// Use of >>
System.out.println(a >> b);
a = -17;
b = 1;
// Use of >>>
System.out.println(a >>> b);
}
}
Output
-8
https://www.geeksforgeeks.org/java-interview-questions/ 23/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
2147483639
The Dot operator in Java is used to access the instance variables and
methods of class objects. It is also used to access classes and sub-packages
from the package.
The covariant return type specifies that the return type may vary in the same
direction as the subclass. It’s possible to have different return types for an
overriding method in the child class, but the child’s return type should be a
subtype of the parent’s return type and because of that overriding method
becomes variant with respect to the return type.
Avoids confusing type casts present in the class hierarchy and makes the
code readable, usable, and maintainable.
Gives liberty to have more specific return types when overriding methods.
Help in preventing run-time ClassCastExceptions on returns.
46. What’s the difference between the methods sleep() and wait()?
https://www.geeksforgeeks.org/java-interview-questions/ 24/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
Sleep() Wait()
The sleep() method belongs to the Wait() method belongs to the object
thread class. class.
Sleep does not release the lock that wait() release the lock which allows
the current thread holds. other threads to acquire it.
Mainly used to delay a thread for Mainly used to pause a thread until
some specific time duration. notified by another thread.
String StringBuffer
https://www.geeksforgeeks.org/java-interview-questions/ 25/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
String StringBuffer
StringBuffer StringBuilder
49. Which among String or String Buffer should be preferred when there
are a lot of updates required to be done in the data?
Example:
https://www.geeksforgeeks.org/java-interview-questions/ 26/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
Java
Output
GeeksforGeeks
51. How is the creation of a String using new() different from that of a
literal?
String using new() is different from the literal as when we declare string it
stores the elements inside the stack memory whereas when it is declared
using new() it allocates a dynamic memory in the heap memory. The object
gets created in the heap memory even if the same content object is present.
Syntax:
https://www.geeksforgeeks.org/java-interview-questions/ 27/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
Syntax:
Arrays in Java are created in heap memory. When an array is created with
the help of a new keyword, memory is allocated in the heap to store the
elements of the array. In Java, the heap memory is managed by the Java
Virtual Machine(JVM) and it is also shared between all threads of the Java
Program. The memory which is no longer in use by the program, JVM uses a
garbage collector to reclaim the memory. Arrays in Java are created
dynamically which means the size of the array is determined during the
runtime of the program. The size of the array is specified during the
declaration of the array and it cannot be changed once the array is created.
There are two types of arrays i.e., Primitive arrays and References Arrays.
Syntax:
https://www.geeksforgeeks.org/java-interview-questions/ 28/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
The index of an array signifies the distance from the start of the array. So,
the first element has 0 distance therefore the starting index is 0.
Syntax:
56. What is the difference between int array[] and int[] array?
Both int array[] and int[] array are used to declare an array of integers in
java. The only difference between them is on their syntax no functionality
difference is present between them.
In Java there are multiple ways to copy an Array based on the requirements.
arraycopy() method: To create a deep copy of the array we can use this
method which creates a new array with the same values as the original
https://www.geeksforgeeks.org/java-interview-questions/ 29/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
array.
Syntax:
value of the Variable is always read from and written to the main memory
when it is defined as volatile rather than being cached in a thread’s local
memory. This makes it easier to make sure that all threads that access the
variable can see changes made to it.
https://www.geeksforgeeks.org/java-interview-questions/ 31/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
Compared to other data structures like linked lists and trees, arrays might
be rigid due to their fixed size and limited support for sophisticated data
types.
Because an array’s elements must all be of the same data type, it does
not support complex data types like objects and structures.
Inheritance
Polymorphism
Abstraction
Encapsulation
Object-oriented programming
The scope of object-based
language covers larger concepts like
programming is limited to the usage
inheritance, polymorphism,
of objects and encapsulation.
abstraction, etc.
https://www.geeksforgeeks.org/java-interview-questions/ 32/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
64. How is the ‘new’ operator different from the ‘newInstance()’ operator
in Java?
the new operator is used to create objects, but if we want to decide the type
of object to be created at runtime, there is no way we can use the new
operator. In this case, we have to use the newInstance() method.
66. What is the difference between static (class) method and instance
method?
Static methods can be called using The instance methods can be called
the class name only without creating on a specific instance of a class using
an instance of a class. the object reference.
Static methods do not have access to Instance methods have access to this
this keyword. keyword.
https://www.geeksforgeeks.org/java-interview-questions/ 33/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
call based on the reference type, not call based on the object type, not on
on the object type. the reference type.
68. What are Brief Access Specifiers and Types of Access Specifiers?
1. Public
2. Private
3. Protected
4. Default
https://www.geeksforgeeks.org/java-interview-questions/ 34/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
69. What will be the initial value of an object reference which is defined
as an instance variable?
The object is a real-life entity that has certain properties and methods
associated with it. The object is also defined as the instance of a class. An
object can be declared using a new keyword.
To know more about methods to create objects in Java refer to this article.
Advantages:
https://www.geeksforgeeks.org/java-interview-questions/ 35/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
Disadvantages:
73. What are the advantages of passing this into a method instead of the
current class object itself?
There are a few advantages of passing this into a method instead of the
current class object itself these are:
this is the final variable because of which this cannot be assigned to any
new value whereas the current class object might not be final and can be
changed.
this can be used in the synchronized block.
Example:
// Class Created
class XYZ{
private int val;
// Constructor
XYZ(){
val=0;
}
};
https://www.geeksforgeeks.org/java-interview-questions/ 36/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
1. Default Constructor
2. Parameterized Constructor
Default Constructor: It is the type that does not accept any parameter value.
It is used to set initial values for object attributes.
class_Name();
// Default constructor called
class_Name(parameter1, parameter2......);
// All the values passed as parameter will be
// allocated accordingly
https://www.geeksforgeeks.org/java-interview-questions/ 37/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
A private constructor is used if you don’t want any other class to instantiate
the object to avoid subclassing. The use private constructor can be seen as
implemented in the example.
Example:
Java
Output
Value of a.x = 20
Value of b.x = 20
80. What are the differences between the constructors and methods?
https://www.geeksforgeeks.org/java-interview-questions/ 38/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
1. Constructors are only called when the object is created but other
methods can be called multiple times during the life of an object.
2. Constructors do not have a return type, whereas methods have a return
type, which can be void or any other type.
3. Constructors are used to setting up the initial state but methods are used
to perform specific actions.
Syntax:
interface
{
// constant fields
// methds that are abstract by default
}
Example:
Java
https://www.geeksforgeeks.org/java-interview-questions/ 39/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
public static void main(String[] args)
{
Circle circle = new Circle(5.0);
System.out.println("Area of circle is "
+ circle.getArea());
System.out.println("Perimeter of circle is"
+ circle.getPerimeter());
}
}
Output
84. What are the differences between abstract class and interface?
https://www.geeksforgeeks.org/java-interview-questions/ 40/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
Abstract Class supports Final The interface class does not support
methods. Final methods.
Abstract Class has members like All class members are public by
protected, private, etc. default.
https://www.geeksforgeeks.org/java-interview-questions/ 41/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
https://www.geeksforgeeks.org/java-interview-questions/ 42/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
Example:
Java
Output
Name is Rohan
Age is 29
https://www.geeksforgeeks.org/java-interview-questions/ 43/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
‘IS-A’ is a type of relationship in OOPs Java where one class inherits another
class.
When an object that belongs to a subclass acquires all the properties and
behavior of a parent object that is from the superclass, it is known as
inheritance. A class within a class is called the subclass and the latter is
referred to as the superclass. Sub class or the child class is said to be
specific whereas the superclass or the parent class is generic. Inheritance
provides code reusability.
Inheritance is the method by which the Child class can inherit the features of
the Super or Parent class. In Java, Inheritance is of four types:
https://www.geeksforgeeks.org/java-interview-questions/ 44/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
Example:
Java
https://www.geeksforgeeks.org/java-interview-questions/ 45/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
d.drink();
d.bark();
}
}
Output
Eating
Drinking
Barking
C++ lets the user to inherit multiple Java doesn’t support multiple
classes. inheritances.
https://www.geeksforgeeks.org/java-interview-questions/ 46/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
Aggregation Composition
https://www.geeksforgeeks.org/java-interview-questions/ 47/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
Aggregation Composition
https://www.geeksforgeeks.org/java-interview-questions/ 48/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
Method overriding, also known as run time polymorphism is one where the
child class contains the same method as the parent class. For instance, we
have a method named ‘gfg()’ in the parent class. A method gfg() is again
defined in the sub-class. Thus when gfg() is called in the subclass, the
method within the class id executed. Here, gfg() within the class overridden
the method outside.
https://www.geeksforgeeks.org/java-interview-questions/ 49/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
No, as static methods are part of the class rather than the object so we can’t
override them.
Yes in Java we can overload the main method to call the main method with
the help of its predefined calling method.
Example:
Java
https://www.geeksforgeeks.org/java-interview-questions/ 50/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
Output
Example:
Java
https://www.geeksforgeeks.org/java-interview-questions/ 51/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
Output
When two or multiple methods are in When a subclass provides its own
the same class with different implementation of a method that is
parameters but the same name. already defined in the parent class.
https://www.geeksforgeeks.org/java-interview-questions/ 52/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
class in which it is declared. Since this method is not visible to other classes
and cannot be accessed, it cannot be overridden.
110. Can we change the scope of the overridden method in the subclass?
111. Can we modify the throws clause of the superclass method while
overriding it in the subclass?
We can modify the throws clause of the Superclass method with some
limitations, we can change the throws clause of the superclass method
while overriding it in the subclass. The subclass overridden method can only
specify unchecked exceptions if the superclass method does not declare any
exceptions. If the superclass method declares an exception, the subclass
method can declare the same exception, a subclass exception, or no
exception at all. However, the subclass method cannot declare a parent
exception that is broader than the ones declared in the superclass method.
Yes, Java supports virtual functions. Functions are by default virtual and can
be made non-virtual using the final keyword.
Java
Output
116. How can you avoid serialization in the child class if the base class is
implementing the Serializable interface?
https://www.geeksforgeeks.org/java-interview-questions/ 54/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
1. Collection Interface
2. List Interface
3. Set Interface
4. Queue Interface
5. Deque Interface
6. Map Interface
Syntax:
1. Using Collections.synchronizedList()
2. Using CopyOnWriteArrayList
Using Collections.synchronizedList():
Using CopyOnWriteArrayList:
122. Can you explain how elements are stored in memory for both
regular arrays and ArrayLists in Java? . Explain.
https://www.geeksforgeeks.org/java-interview-questions/ 56/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
Syntax:
Arrays.asList(item)
Example:
Java
https://www.geeksforgeeks.org/java-interview-questions/ 57/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
}
}
Output
Syntax:
List_object.toArray(new String[List_object.size()])
Example:
Java
import java.util.List;
import java.util.ArrayList;
// Driver Class
class GFG {
// Main Function
public static void main(String[] args) {
// List declared
List<Integer> arr = new ArrayList<>();
arr.add(1);
arr.add(2);
arr.add(3);
arr.add(2);
arr.add(1);
// Conversion
Object[] objects = arr.toArray();
https://www.geeksforgeeks.org/java-interview-questions/ 58/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
// Printing array of objects
for (Object obj : objects)
System.out.print(obj + " ");
}
}
Output
1 2 3 2 1
124. How does the size of ArrayList grow dynamically? And also state
how it is implemented internally.
Vectors in Java are similar and can store multiple elements inside them.
Vectors follow certain rules mentioned below:
Syntax:
https://www.geeksforgeeks.org/java-interview-questions/ 59/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
Syntax:
array_readonly = Collections.unmodifiableList(ArrayList);
Example:
Java
import java.util.*;
Output
https://www.geeksforgeeks.org/java-interview-questions/ 60/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
Syntax:
Java
import java.util.*;
class PriorityQueueDemo {
// Main Method
public static void main(String args[]) {
// Creating empty priority queue
PriorityQueue<Integer> var1 = new PriorityQueue<Integer>();
// Adding items to the pQueue using add()
var1.add(10);
var1.add(20);
var1.add(15);
// Printing the top element of PriorityQueue
System.out.println(var1.peek());
}
}
https://www.geeksforgeeks.org/java-interview-questions/ 61/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
Output
10
LinkedList class is Java that uses a doubly linked list to store elements. It
inherits the AbstractList class and implements List and Deque interfaces.
Properties of the LinkedList Class are mentioned below:
Syntax:
129. What is the Stack class in Java and what are the various methods
provided by it?
A Stack class in Java is a LIFO data structure that implements the Last In
First Out data structure. It is derived from a Vector class but has functions
specific to stacks. The Stack class in java provides the following methods:
peek(): returns the top item from the stack without removing it
empty(): returns true if the stack is empty and false otherwise
push(): pushes an item onto the top of the stack
pop(): removes and returns the top item from the stack
search(): returns the 1, based position of the object from the top of the
stack. If the object is not in the stack, it returns -1
130. What is Set in the Java Collections framework and list down its
various implementations?
Sets are collections that don’t store duplicate elements. They don’t keep any
order of the elements. The Java Collections framework provides several
implementations of the Set interface, including:
https://www.geeksforgeeks.org/java-interview-questions/ 62/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
131. What is the HashSet class in Java and how does it store elements?
The HashSet class implements the Set interface in the Java Collections
Framework and is a member of the HashSet class. Unlike duplicate values, it
stores a collection of distinct elements. In this implementation, each element
is mapped to an index in an array using a hash function, and the index is
used to quickly access the element. It produces an index for the element in
the array where it is stored based on the input element. Assuming the hash
function distributes the elements among the buckets appropriately, the
HashSet class provides constant-time performance for basic operations
(add, remove, contain, and size).
Syntax:
Example:
Java
import java.io.*;
import java.util.*;
// Driver Class
class GFG {
// Main Function
public static void main(String[] args) {
https://www.geeksforgeeks.org/java-interview-questions/ 63/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
// LinkedHashSet declared
LinkedHashSet<Integer> hs = new LinkedHashSet<Integer>();
// Add elements in HashSet
hs.add(1);
hs.add(2);
hs.add(5);
hs.add(3);
// Print values
System.out.println("Values:" + hs);
}
}
Output
Values:[1, 2, 5, 3]
The map interface is present in the Java collection and can be used with
Java.util package. A map interface is used for mapping values in the form of
a key-value form. The map contains all unique keys. Also, it provides
methods associated with it like containsKey(), contains value (), etc.
There are multiple types of maps in the map interface as mentioned below:
1. SortedMap
2. TreeMap
3. HashMap
4. LinkedHashMap
https://www.geeksforgeeks.org/java-interview-questions/ 64/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
TreeMap is a type of map that stores data in the form of key-value pair. It is
implemented using the red-black tree. Features of TreeMap are :
1. It is non-synchronized.
2. Faster than HashSet.
3. All of the elements in an EnumSet must come from a single enumeration
type.
4. It doesn’t allow null Objects and throws NullPointerException for
exceptions.
5. It uses a fail-safe iterator.
Syntax:
A blocking queue is a Queue that supports the operations that wait for the
queue to become non-empty while retrieving and removing the element, and
https://www.geeksforgeeks.org/java-interview-questions/ 65/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
wait for space to become available in the queue while adding the element.
Syntax:
Syntax:
Parameters: K is the key Object type and V is the value Object type
Yes, we can use any class as a Map Key if it follows certain predefined rules
mentioned below:
1. The class overriding the equals() method must also override the
hashCode() method
2. The concurrentHashMap class is thread-safe.
3. The default concurrency level of ConcurrentHashMap is 16.
4. Inserting null objects in ConcurrentHashMap is not possible as a key or as
value.
https://www.geeksforgeeks.org/java-interview-questions/ 66/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
The Iterator interface provides methods to iterate over any Collection in Java.
Iterator is the replacement of Enumeration in the Java Collections
Framework. It can get an iterator instance from a Collection using the
_iterator()_ method. It also allows the caller to remove elements from the
underlying collection during the iteration.
Example:
Collection Collections
https://www.geeksforgeeks.org/java-interview-questions/ 67/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
Collection Collections
It provides the methods that can be It provides static methods that can be
used for the data structure. used for various operations.
Array ArrayList
Single-dimensional or
Single-dimensional
multidimensional
length keyword returns the size of the size() method is used to compute the
array. size of ArrayList.
They can not be added here hence the They can be added here hence
type is in the unsafe. makingArrayList type-safe.
https://www.geeksforgeeks.org/java-interview-questions/ 68/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
Array ArrayList
The assignment operator only serves Here a special method is used known
the purpose as add() method
Array Collections
Objects and primitive data types can We can only store objects in
be stored in an array. collections.
The array has basic methods for Collections have advanced methods
manipulation. for manipulation and iteration.
ArrayList LinkedList
https://www.geeksforgeeks.org/java-interview-questions/ 69/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
ArrayList LinkedList
ArrayLists are faster for random LinkedLists are faster for insertion and
access. deletion operations
ArrayList Vector
https://www.geeksforgeeks.org/java-interview-questions/ 70/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
ArrayList Vector
Iterator ListIterator
Can’t add elements, and also throws Can easily add elements to a
ConcurrentModificationException. collection at any time.
https://www.geeksforgeeks.org/java-interview-questions/ 71/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
Iterator ListIterator
HashMap HashTable
Iterator Enumeration
https://www.geeksforgeeks.org/java-interview-questions/ 72/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
Iterator Enumeration
Comparable Comparator
Method sorts the data according to Method sorts the data according to
fixed sorting order. the customized sorting order.
https://www.geeksforgeeks.org/java-interview-questions/ 73/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
Set Map
The set can sort only one null value. The map can sort multiple null values.
151. Explain the FailFast iterator and FailSafe iterator along with
examples for each.
Example:
Java
import java.io.*;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
class GFG {
public static void main(String[] args) {
HashMap<Integer, String> map = new HashMap<>();
map.put(1, "one");
map.put(2, "two");
https://www.geeksforgeeks.org/java-interview-questions/ 74/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
if (entry.getKey() == 1) {
map.remove(1);
}
}
}
}
Output:
Example:
Java
import java.io.*;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
class GFG {
public static void main(String[] args) {
ConcurrentHashMap<Integer, String> map = new
ConcurrentHashMap<>();
map.put(1, "one");
map.put(2, "two");
https://www.geeksforgeeks.org/java-interview-questions/ 75/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
An Exception is an Event that interrupts the normal flow of the program and
requires special processing. During the execution of a program, errors and
unplanned occurrences can be dealt with by using the Java Exception
Handling mechanism. Below are some reasons why Exceptions occur in Java:
Device failure
Loss of Network Connection
Code Errors
Opening an Unavailable file
Invalid User Input
Physical Limitations (out of disk memory)
https://www.geeksforgeeks.org/java-interview-questions/ 76/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
Errors Exceptions
Errors can occur at compile time as All exceptions occur at runtime but
well as run time. Compile Time: checked exceptions are known to the
Syntax Error, Run Time: Logical Error. compiler while unchecked are not.
https://www.geeksforgeeks.org/java-interview-questions/ 77/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
All exception and error types in Java are subclasses of the class throwable,
which is the base class of the hierarchy. This class is then used for
exceptional conditions that user programs should catch.
NullPointerException is an example of such an exception. Another branch,
error is used by the Java run-time system to indicate errors having to do with
the JRE. StackOverflowError is an example of one of such error.
Runtime Exceptions are exceptions that occur during the execution of a code,
as opposed to compile-time exceptions that occur during compilation.
Runtime exceptions are unchecked exceptions, as they aren’t accounted for
by the JVM.
https://www.geeksforgeeks.org/java-interview-questions/ 78/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
Example:
Java
Example:
https://www.geeksforgeeks.org/java-interview-questions/ 79/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
Checked Exception:
Checked Exceptions are the exceptions that are checked during compile time
of a program. In a program, if some code within a method throws a checked
exception, then the method must either handle the exception or must specify
the exception using the throws keyword.
Fully checked exceptions: all its child classes are also checked, like
IOException, and InterruptedException.
Partially checked exceptions: some of its child classes are unchecked, like
an Exception.
Unchecked Exception:
Unchecked are the exceptions that are not checked at compile time of a
program. Exceptions under Error and RuntimeException classes are
unchecked exceptions, everything else under throwable is checked.
No, It is not necessary to use catch block after try block in Java as we can
create another combination with finally block. Finally is the block which runs
despite the fact that the exception is thrown or not.
163. What will happen if you put System.exit(0) on the try or catch
block? Will finally block execute?
164. What do you understand by Object Cloning and how do you achieve
it in Java?
https://www.geeksforgeeks.org/java-interview-questions/ 81/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
not executed.
The final keyword is used to make functions non-virtual. By default, all the
functions are virtual so to make it non-virtual we use the final keyword.
167. What purpose do the keywords final, finally, and finalize fulfill?
i). final:
final is a keyword is used with the variable, method, or class so that they
can’t be overridden.
Example:
Java
Output:
ii). finally
Example:
https://www.geeksforgeeks.org/java-interview-questions/ 82/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
Java
Output
Try block
Always runs even without exceptions
iii). finalize
Example:
Java
https://www.geeksforgeeks.org/java-interview-questions/ 83/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
}
}
Output
this( ) super( )
Calls the default constructor of the Calls the default constructor of the
same class. base class.
Access the methods of the same Access the methods of the parent
class. class.
Example:
Java
https://www.geeksforgeeks.org/java-interview-questions/ 84/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
https://www.geeksforgeeks.org/java-interview-questions/ 85/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
172. What are the two ways in which Thread can be created?
Syntax:
Syntax:
https://www.geeksforgeeks.org/java-interview-questions/ 86/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
Threads in Java are subprocess with lightweight with the smallest unit of
processes and also has separate paths of execution. These threads use
shared memory but they act independently hence if there is an exception in
threads that do not affect the working of other threads despite them sharing
the same memory. A thread has its own program counter, execution stack,
and local variables, but it shares the same memory space with other threads
in the same process. Java provides built-in support for multithreading
through the Runnable interface and the Thread class.
A process and a thread are both units of execution in a computer system, but
they are different in several ways:
Process Thread
The process takes more time to The thread takes less time to
terminate. terminate.
The process takes more time for The thread takes less time for context
context switching. switching.
https://www.geeksforgeeks.org/java-interview-questions/ 87/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
Process Thread
The process has its own Process Thread has Parents’ PCB, its own
Control Block, Stack, and Address Thread Control Block, and Stack and
Space. common Address space.
A thread in Java at any point in time exists in any one of the following states.
A thread lies only in one of the shown states at any instant:
1. New: The thread has been created but has not yet started.
2. Runnable: The thread is running, executing its task, or is ready to run if
there are no other higher-priority threads.
3. Blocked: The thread is temporarily suspended, waiting for a resource or
an event.
4. Waiting: The thread is waiting for another thread to perform a task or for
a specified amount of time to elapse.
5. Terminated: The thread has completed its task or been terminated by
another thread.
https://www.geeksforgeeks.org/java-interview-questions/ 88/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
The suspend() method of the Thread class in Java temporarily suspends the
execution of a thread. When a thread is suspended it goes into a blocked
state and it would not be scheduled by the operating system which means
that it will not be able to execute its task until it is resumed. There are more
safer and flexible alternatives to the suspend() methods in the modern java
programming language. This method does not return any value.
Syntax:
Example:
Java
Output:
Thread running: 0
Thread running: 1
Thread running: 2
Suspended thread
Resumed thread
Thread running: 3
Thread running: 4
Thread running: 5
Thread running: 6
Thread running: 7
Thread running: 8
Thread running: 9
https://www.geeksforgeeks.org/java-interview-questions/ 90/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
179. What are the ways in which a thread can enter the waiting state?
Thread is a lightweight process that runs concurrently with the other thread
inside a single process. Each thread can execute a different task and share
the resources within a single process. Thread in Java can enter the waiting
state in many different ways:
Sleep() method Call: The sleep () method is used to pause the execution
of the thread for a specific amount of time. While the thread is paused it
goes into the waiting state.
Wait() method: This method is used to wait a thread until the other
thread signals it to wake up. Thread goes into the waiting state until it
receives a notification from another thread.
Join() method: Join() method can be used to wait for thread to finish the
execution. Calling thread goes into the waiting state until the target
thread is completed.
Waiting for I/O operations: If the thread is waiting for Input/Output
operation to complete, it goes into the waiting state until the operation is
finished.
Synchronization Issues: If there are any synchronization issues in a multi-
threaded application, threads may go into the waiting state until the
synchronization issues are resolved.
https://www.geeksforgeeks.org/java-interview-questions/ 91/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
In order to stop threads from interacting with one another and creating race
situations or other issues, Java has a number of ways to govern the behavior
of threads, including synchronization and locking. It is feasible to create
multi-threaded programmers that operate correctly and effectively on a
machine with a single CPU by regulating the interaction between threads
and making sure that crucial code parts are synchronized. In contrast to
running the same program on a computer with multiple CPUs or cores,
multi-threading on a single CPU can only give the appearance of parallelism,
and actual performance gains may be modest. The operating system divides
the CPU time that is available when numerous threads are running on a
single CPU into small time slices and gives each thread a time slice to
execute. Rapid switching between the threads by the operating system
creates the appearance of parallel execution. The switching between
threads appears to be immediate because the time slices are often very tiny,
on the order of milliseconds or microseconds.
181. What are the different types of Thread Priorities in Java? And what
is the default priority of a thread assigned by JVM?
MIN_PRIORITY
MAX_PRIORITY
NORM_PRIORITY
https://www.geeksforgeeks.org/java-interview-questions/ 92/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
For Java, Garbage collection is necessary to avoid memory leaks which can
cause the program to crash and become unstable. There is no way to avoid
garbage collection in Java. Unlike C++, Garbage collection in Java helps
programmers to focus on the development of the application instead of
managing memory resources and worrying about memory leakage. Java
Virtual Machine (JVM) automatically manages the memory periodically by
running a garbage collector which frees up the unused memory in the
application. Garbage collection makes Java memory efficient because it
removes unreferenced objects from the heap memory.
184. Explain the difference between a minor, major, and full garbage
collection.
The Java Virtual Machine (JVM) removes objects that are no longer in use
using a garbage collector which periodically checks and removes these
objects. There are different types of garbage collection in the JVM, each with
different characteristics and performance implications. The main types of
garbage collection are:
https://www.geeksforgeeks.org/java-interview-questions/ 93/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
185. How will you identify major and minor garbage collections in Java?
Major garbage collection works on the survivor space and Minor garbage
collection works on the Eden space to perform a mark-and-sweep routine.
And we can identify both of them based on the output where the minor
collection prints “GC”, whereas the major collection prints “Full GC” for the
case where the garbage collection logging is enabled with “-
XX:PrintGCDetails” or “verbose:gc”.
186. What is a memory leak, and how does it affect garbage collection?
Example:
Java
https://www.geeksforgeeks.org/java-interview-questions/ 94/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
Output:
https://www.geeksforgeeks.org/java-interview-questions/ 95/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
regex = “^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&-+=()])(?
=\\S+$).{8, 20}$”
Explanation:
JDBC standard API is used to link Java applications and relational databases.
It provides a collection of classes and interfaces that let programmers to use
the Java programming language to communicate with the database. The
classes and interface of JDBC allow the application to send requests which
are made by users to the specified database. There are generally four
components of JDBC by which it interacts with the database:
JDBC API
JDBC Driver manager
JDBC Test Suite
JDBC-ODBC Bridge Drivers
https://www.geeksforgeeks.org/java-interview-questions/ 96/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
There are certain steps to connect the database and Java Program as
mentioned below:
https://www.geeksforgeeks.org/java-interview-questions/ 97/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
JDBC API components provide various methods and interfaces for easy
communication with the databases also it provides packages like java Se and
java EE which provides the capability of write once run anywhere (WORA).
Syntax:
java.sql.*;
JDBC ResultSet interface is used to store the data from the database and
use it in our Java Program. We can also use ResultSet to update the data
using updateXXX() methods. ResultSet object points the cursor before the
first row of the result data. Using the next() method, we can iterate through
the ResultSet.
A JDBC RowSet provides a way to store the data in tabular form. RowSet is
an interface in java that can be used within the java.sql package. The
connection between the RowSet object and the data source is maintained
throughout its life cycle. RowSets are classified into five categories based on
implementation mentioned below:
https://www.geeksforgeeks.org/java-interview-questions/ 98/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
1. JdbcRowSet
2. CachedRowSet
3. WebRowSet
4. FilteredRowSet
5. JoinRowSet
Iterable Iterator
https://www.geeksforgeeks.org/java-interview-questions/ 99/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
List Set
Ordered Unordered
Multiple null elements can be stored. Null element can store only once.
List Map
https://www.geeksforgeeks.org/java-interview-questions/ 100/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
Queue Stack
Queue data structure is used to store Stack data structure is used to store
elements, and is used to perform elements, and is used to perform
operations like enqueue, dequeue operations like push, pop from top of
from back or end of the queue. the stack.
This data structure allows duplicate This data structure does not allow
elements duplicate elements
https://www.geeksforgeeks.org/java-interview-questions/ 101/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
202. Differentiate between the Singly Linked List and Doubly Linked List.
Singly Linked List contain only two Doubly Linked List contains three
segments i.e, Data and Link. segments i.e, Data, and two pointers.
Easy to use and insert nodes at the Slightly more complex to use and
beginning of the list. easy to insert at the end of the list.
The time complexity of insertion and The time complexity of insertion and
deletion is O(n). deletion is O(1).
https://www.geeksforgeeks.org/java-interview-questions/ 102/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
FailFast FailSafe
Failfast does not allow any modification Failsafe allows modification during
while iteration. the time of iteration.
FailFast throws
ConcurrentModificationException if the FailSafe does not throws any
HashMap TreeMap
https://www.geeksforgeeks.org/java-interview-questions/ 103/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
HashMap TreeMap
Queue Deque
https://www.geeksforgeeks.org/java-interview-questions/ 104/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
Queue Deque
HashSet TreeSet
HashSet allows null elements. TreeSet does not allow null elements.
https://www.geeksforgeeks.org/java-interview-questions/ 105/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
than any other developer role. Here you can also check our latest
course on Java Backend Development!
Q3. What are the essential skills required for a Java developer?
https://www.geeksforgeeks.org/java-interview-questions/ 106/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
GeeksforGeeks 103
Similar Reads
Data Engineer Interview Questions: Top 60 Plus Questions and Answers f…
Data engineering is a rapidly growing field that plays a crucial role in
managing and processing large volumes of data for organizations. As…
15+ min read
Kafka Interview Questions - Top 70+ Questions and Answers for 2024
https://www.geeksforgeeks.org/java-interview-questions/ 107/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
https://www.geeksforgeeks.org/java-interview-questions/ 108/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
4 min read
+1 More
Company Explore
About Us Job-A-Thon Hiring Challenge
Legal Hack-A-Thon
Careers GfG Weekly Contest
In Media Offline Classes (Delhi/NCR)
Contact Us DSA in JAVA/C++
Advertise with us Master System Design
GFG Corporate Solution Master CP
Placement Training Program GeeksforGeeks Videos
Geeks Community
Languages DSA
Python Data Structures
Java Algorithms
C++ DSA for Beginners
https://www.geeksforgeeks.org/java-interview-questions/ 109/111
8/4/24, 5:49 PM 200+ Core Java Interview Questions and Answers (2024)
PHP Basic DSA Problems
GoLang DSA Roadmap
SQL DSA Interview Questions
R Language Competitive Programming
Android Tutorial
https://www.geeksforgeeks.org/java-interview-questions/ 111/111