Frequently asked Interview Questions of Java for Freshers and Experienced Professionals

Some of the frequently asked Interview questions for Java developers are:

Basic Java
1   What is an object?
2   What is method overriding in java ?
3   What is a super keyword in java ?
4   What is method overloading in java ?
5   What is the difference between c++ and Java ?
6 What is JIT compiler ?
7   What is bytecode in java ?
8   Difference between method overloading and method overriding in java ?
9   Difference between abstract class and interface ?
10   Why java is platform independent?
11 Difference between this( and super( in java ?
12 How to call one constructor from the other constructor ?
13 what are static blocks and static initalizers in Java ?
14 What is a method in java ?
15 What is a constructor in java ?
17 Difference between Character Constant and String Constant in java ?
18 Why main( method is public, static and void in java ?
19 Explain about main( method in java ?
20 What is the difference between length and length( method in java ?
21   What  is ASCII Code?
22 What is Unicode ?
23 What are constants and how to create constants in java?

OOPS
24 Explain about object oriented programming and its features?
25 What is Abstraction?
26 What is Encapsulation?
27 What is the difference between abstraction and encapsulation?
28 List out benefits of object oriented programming language?
29 Differences between traditional programming language and object oriented programming language?
30 What is Inheritance?
31 What is Polymorphism?
32 How does Java implement polymorphism?
33 Explain the different forms of Polymorphism
34 What is runtime polymorphism or dynamic method dispatch?
35 What is Dynamic Binding?
36 What is method overloading?
37 What is method overriding?
38 What are the differences between method overloading and method overriding?
39 Can overloaded methods be override too?
40 Is it possible to override the main method?
41 How to invoke a superclass version of an Overridden method?
42 What is super?
43 How do you prevent a method from being overridden?
44 What is an Interface?
45 Can we instantiate an interface?
46 Can we create an object for an interface?
47 Do interfaces have member variables?
48 What modifiers are allowed for methods in an Interface?
49 What is a marker interface?
50 What is an abstract class?
51 Can we instantiate an abstract class?
52 What are the differences between Interface and Abstract class?
53 When should I use abstract classes and when should I use interfaces?
54 When you declare a method as abstract, can other nonabstract methods access it?
55 Can there be an abstract class with no abstract methods in it?
56 What is IS-A relationship  in java?
57 What is HAS A relationship in java?
58 Difference between IS-A and HAS-A relationship in java?
59 Explain about instanceof operator in java?
60   What does null mean in java?
61   Can we have multiple classes in a single file ?
62   What all access modifiers are allowed for top class ?
63 What are packages in java?
64   Can we have more than one package statement in the source file ?
65   Can we define package statement after import statement in java?
66 What are identifiers in  java?
67 What are access modifiers in java?
68   What is the difference between access specifiers and access modifiers in java?
69   What access modifiers can be used for class ?
70   Explain what access modifiers can be used for methods?
71   Explain what access modifiers can be used for variables?
72   What is final access modifier in java?
73   Explain about abstract classes in java?
74 Can we create constructor in abstract class ?
75   What are abstract methods in java?

Type Casting

76 What is TypeConversion?
77 Explain Implicit Conversion/ Widening/Automatic Type Conversion?
78 What is Explicit Conversion/Narrowing/Casting?
79 Can a double value be cast to the byte? How to cast a double value to byte with help of the example?
80 Can a Boolean primitive value to be converted to any other primitive in java?
81 What is autoboxing and autounboxing?
82 What are advantages of autoboxing and autounboxing?
83 How to cast objects or what is object casting?
84 What is upcasting or downcasting?

Exception Handling

85   State some situations where exceptions may arise in java?
86   What is Exception handling in java?
87    What is an eror in Java?
88   What are advantages of Exception handling in java?
89   In how many ways we can do exception handling in java?
90   List out five keywords related to Exception handling ?
91   Explain try and catch keywords in java?
92   Can we have try block without catch block?
93    Can we have multiple catch block for a try block?
94   Explain the importance of finally block in java?
95   Can we have any code between try and catch blocks?
96   Can we have any code between try and finally blocks?
97   Can we catch more than one exception in the single catch block?
98   What are checked Exceptions?
99   What are unchecked exceptions in java?
100   Explain differences between checked and Unchecked exceptions in java?
101 What is default Exception handling in java?
102   Explain throw keyword in java?
103   Can we write any code after throw statement?
104 Explain the importance of throws keyword in java?
105 Explain the importance of finally over return statement?
106 Explain a situation where finally block will not be executed?
107   Can we use catch statement for checked exceptions?
108   What are user-defined exceptions?
109   Can we rethrow the same exception from catch handler?
110   Can we nest try statements in java?
111 Explain the importance of throwable class and its methods?
112 Explain when ClassNotFoundException will be raised ?
113 Explain  when NoClassDefFoundError  will be raised ?

Nested Class & Inner Class

114 What are inner classes or non static nested classes in java?
115   Why to use nested classes in java?
116   Explain about static nested classes in java?
117 How to instantiate static nested classes in java?
118   Explain about method local inner classes or local inner classes in java?
119 Explain about features of local inner class?
120 Explain about anonymous inner classes in java?
121 Explain restrictions for using anonymous inner classes?
122   Is this valid in java ? can we instantiate interface in java?
123 Explain about member inner classes?
124 How to instantiate member inner class?
125 How to do encapsulation in java?
126 What are reference variables in java ?
127 Will the compiler creates a default constructor if I have a parameterized constructor in the class?
128   Can we have a method name same as class name in java?
129   Can we override constructors in java?
130 Can Static methods access instance variables in java?
131 How do we access static members in java?
132    Can we override static methods in java?
133 Difference between object and reference?
134 Objects or references which of them gets garbage collected?
135 How many times finalize method will be invoked ? who invokes finalize( method in java?
136 Can we able to pass objects as an arguments in java?
137 Explain wrapper classes in java?
138 Explain different types of wrapper classes in java?
139 Explain about transient variables in java?
140 Can we serialize static variables in java?
141   What is type conversion in java?
142   Explain about Automatic type conversion in java?
143 Explain about narrowing conversion in java?
144 Explain the importance of import keyword in java?
145 Explain naming conventions for packages ?
146 What is classpath ?
147 What is jar ?
148 What is the scope or life time of instance variables ?
149 Explain the scope or life time of class variables or static variables?
150 Explain scope or life time of local variables in java?
151   Explain about static imports in java?
152 Can we define static methods inside interface?
153 Define interface in java?
154 What is the purpose of interface?
155 Explain features of interfaces in java?
156 Explain enumeration in java?
157 Explain restrictions on  using enum?
158 Explain about field hiding in java?
159   Explain about Varargs in java?
160 Explain where variables are created in memory?
161 Can we use Switch statement with Strings?
162 In java how do we copy objects?

Theads

163 What is a thread in java?
164   Difference between process and thread?
165   What is multitasking ?
166   What are different types of multitasking?
167   What are the benefits of multithreaded programming?
168   Explain thread in java?
169   List Java API that supports threads?
170   Explain about main thread in java?
171   In how many ways we can create threads in java?
172   Explain creating threads by implementing Runnable class?
173 Explain creating threads by extending Thread class?
174 Which is the best approach for creating a thread?
175   Explain the importance of thread scheduler in java?
176   Explain the life cycle of the thread?
177   Can we restart a dead thread in java?
178   Can one thread block the other thread?
179 Can we restart a thread already started in java?
180 What happens if we don’t override run method?
181   Can we overload run ( method in java?
182 What is a lock or purpose of locks in java?
183   In how many ways we can do synchronization in java?
184   What are synchronized methods?
185 When do we use synchronized methods in java?
186   When a thread is executing synchronized methods, then is it possible to execute other synchronized methods simultaneously by other threads?
187 When a thread is executing a synchronized method, then is it possible for the same thread to access other synchronized methods of an object ?
188 What are synchronized blocks in java?
189   When do we use synchronized blocks and advantages of using synchronized blocks?
190   What is class level lock ?
191   Can we synchronize static methods in java?
192   Can we use synchronized block for primitives?
193   What are thread priorities and importance of thread priorities in java?
194   Explain different types of thread priorities ?
195   How to change the priority of thread or how to set priority of thread?
196   If two threads have same priority which thread will be executed first ?
197 What all methods are used to prevent thread execution ?
198 Explain yield( method in thread class ?
199   Is it possible for yielded thread to get chance for its execution again ?
200 Explain the importance of join( method in thread class?
201   Explain purpose of sleep( method in java?
202   Assume a thread has lock on it, calling sleep( method on that thread will release the lock?
203 Can sleep() method causes another thread to sleep?
204 Explain about interrupt() method of thread class ?
205 Explain about interthread communication and how it takes place in java?
206 Explain wait() , notify() and notifyAll() methods of object class ?
207 Explain why wait(), notify() and notifyAll() methods are in Object class rather than in thread class?
208 Explain IllegalMonitorStateException and when it will be thrown?
209   when wait(), notify(),notifyAll() methods are called does it releases the lock or holds the acquired lock?
210   Explain which of the following methods releases the lock when yield(), join(),sleep(),wait(),notify(), notifyAll()methods are executed?
211   What are thread groups?
212 What are thread local variables ?
213 What are daemon threads in java?
214 How to make a non daemon thread as daemon?
215 Can we make main() thread as daemon?

Collection Framework

216 What is the collection?
217 Difference between collection, Collection, and Collections in java?
218 Explain about Collection interface in java?
219 List the interfaces which extend collection interface?
220 Explain List interface?
221 Explain methods specific to List interface?
222 List implementations of List Interface?
223   Explain about ArrayList?
224 Difference between Array and ArrayList?
225   What is vector?
226 Difference between ArrayList and vector?
227   Define  Linked List and its features with signature?
228   Define Iterator and methods in Iterator?
229 In which order the Iterator iterates over collection?
230   Explain ListIterator and methods in ListIterator?
231 Explain about Sets?
232 Implementations of Set interface?
233   Explain HashSet and its features?
234 Explain Tree Set and its features?
235 When do we use HashSet over TreeSet?
236 What is Linked HashSet and its features?
237 Explain about Map interface in java?
238 What is linked hashmap and its features?
239   What is SortedMap interface?
240   What is Hashtable and explain features of Hashtable?
241 Difference between HashMap and Hashtable?
242 Difference between ArrayList and linked list?
243 Difference between Comparator and  Comparable in java?
244 What is concurrent hashmap and its features?
245 Difference between Concurrent HashMap and Hashtable and collections.synchronizedHashMap?
246 Explain copyOnWriteArrayList and when do we use copyOnWriteArrayList?
247 Explain about fail-fast iterators in java?
248 Explain about fail-safe iterators in java?

Serialization

249 What is serialization in java?
250 What is the main purpose of serialization in java?
251 What are alternatives to java serialization?
252 Explain about the serializable interface in java?
253 How to make an object serializable in java?
254 What is serial version UID and its importance in java?
255 What happens if we don’t define serial version UID?
256 Can we serialize static variables in java?
257 When we serialize an object does the serialization mechanism saves its references too?
258 If we don’t want some of the fields not to serialize How to do that?
259 Explain the importance of object class in java?
260 Explain the purpose of the object class or why object class is a super class for all java classes?
261 Explain Object class methods?
262 List methods which can be overrided from Object class?
263 Explain the purpose of toString( method in java?

Strings
264 Explain Strings in java?
265 Difference between Strings and Character Arrays in java?
266 Explain the importance of String class in java?
267 In how many ways we can create Strings in java?
268 Explain how to create Strings using String literal and advantages of creating Strings using String literal?
Class Loaders
269 What are classloaders and different types of class loaders in java?
270 What is BootStrap class loader and how does it works?
271 What is Extensions class loader and how does it works?
272 What is application class loader and how does it works?
273 When an object becomes eligible for garbage collection?
274 Who performs garbage collection?
275 When does garbage collector run?
276 Which algorithm garbage collector uses to perform garbage collection?
277 List out different garbage collection algorithms?
278 Can we force JVM for garbage collection?
279 How to request jvm to perform garbage collection operation?
280 Explain the purpose of finalize method in relation to Garbage collection?
281 How many times finalize method is called on an Object?
282 Once an object is garbage collected can it become reachable again?
283 How to write a code that makes an object eligible for garbage collection?