1. Which two method you need to implement for key Object
in HashMap?
2. What is immutable object? Can you write immutable
object?
3. What is the difference between creating String as
new() and literal?
5. Write code to find the First non repeated character in
the String ?
6. What is the difference between ArrayList and Vector ?
7. How do you handle error condition while
writing stored procedure or accessing stored procedure from java?
8. What is difference etween Executor.submit() and Executer.execute() method
?
9. What is the difference between factory and abstract
factory pattern?
10. What is Singleton? is it better to make whole method
synchronized or only critical section synchronized ?
11. Can you write critical section code for
singleton?
12. Can you write code for iterating over hashmap in Java 4 and
Java 5 ?
13. When do you override hashcode and equals() ?
14. What will be the problem if you don't override
hashcode() method ?
15. Is it better to synchronize critical section of
getInstance() method or whole getInstance() method ?
16. What is the difference when String is gets created
using literal or new() operator ?
17. Does not overriding hashcode() method has any
performance implication ?
18. What’s wrong using HashMap in multithreaded
environment? When get() method go to infinite loop ?
19. What do you understand by thread-safety ? Why is
it required ? And finally, how to achieve thread-safety in Java Applications ?
20. What will happen if you call return statement or
System.exit on try or catch block ? will finally block execute?
21. Can you override private or static method in Java ?
22. What will happen if we put a key object in a HashMap
which is already there ?
23. If a method throws NullPointerException in super
class, can we override it with a method which throws RuntimeException?
24. What is the issue with following implementation of
compareTo() method in Java
25. How do you ensure that N thread can access N resources
without deadlock
26. What is difference between CyclicBarrier and
CountDownLatch in Java
27. Can you access non static variable in static context?
28. What
is the difference between creating String as new() and literal?
When we create string with new() Operator, it’s
created in heap and not added into string pool
29. What
are the important features of Java 8 release?
30. .
31. What
do you mean by platform independence of Java?
32. What
is JVM and is it platform independent?
33. What
is the difference between JDK and JVM?
34. What
is the difference between JVM and JRE?
35. Which
class is the superclass of all classes?
36. Why
Java doesn’t support multiple inheritance?
37. Why
Java is not pure Object Oriented language?
38. What
is difference between path and classpath variables?
39. What
is the importance of main method in Java?
40. What
is overloading and overriding in java?
41. Can
we overload main method?
42. Can
we have multiple public classes in a java source file?
43. What
is Java Package and which package is imported by default?
44. What
are access modifiers?
45. What
is final keyword?
46. What
is static keyword?
47. What
is finally and finalize in java?
48. Can
we declare a class as static?
49. What
is static import?
50. What
is try-with-resources in java?
51. What
is multi-catch block in java?
52. What
is static block?
53. What
is an interface?
54. What
is an abstract class?
55. What
is the difference between abstract class and interface?
56. Can
an interface implement or extend another interface?
57. What
is Marker interface?
58. What
are Wrapper classes?
59. What
is Enum in Java?
60. What
is Java Annotations?
61. What
is Java Reflection API? Why it’s so important to have?
62. What
is composition in java?
63. What
is the benefit of Composition over Inheritance?
64. How
to sort a collection of custom Objects in Java?
65. What
is inner class in java?
66. What
is anonymous inner class?
67. What
is Classloader in Java?
68. What
are different types of classloaders?
69. What
is ternary operator in java?
70. What
does super keyword do?
71. What
is break and continue statement?
72. What
is this keyword?
73. What
is default constructor?
74. Can
we have try without catch block?
75. What
is Garbage Collection?
76. What
is Serialization and Deserialization?
77. How
to run a JAR file through command prompt?
78. What
is the use of System class?
79. What
is instanceof keyword?
80. Can
we use String with switch case?
81. Java
is Pass by Value or Pass by Reference?
82. What
is difference between Heap and Stack Memory?
83. Java
Compiler is stored in JDK, JRE or JVM?
84. What
will be the output of following programs?
85. java interview questions on this keyword
164.
Draw the Architecture
Diagram of your current project.
165.
What
is String in Java? String is a data type?
166.
What
are different ways to create String Object?
167.
Write
a method to check if input String is Palindrome?
168.
Write
a method that will remove given character from the String?
169.
How
can we make String upper case or lower case?
170.
What
is String subSequence method?
171.
How to
compare two Strings in java program?
172.
How to
convert String to char and vice versa?
173.
How to
convert String to byte array and vice versa?
174.
Can we
use String in switch case?
175.
Write
a program to print all permutations of String?
176.
Write
a function to find out longest palindrome in a given string?
177.
Difference
between String, StringBuffer and StringBuilder?
178.
Why
String is immutable or final in Java
179.
How to
Split String in java?
180.
Why
Char array is preferred over String for storing password?
181.
How do
you check if two Strings are equal in Java?
182.
What
is String Pool?
183.
What
does String intern() method do?
184.
Does
String is thread-safe in Java?
185.
Why
String is popular HashMap key in Java?
186.
Why is
String immutable in Java?
187.
Can
abstract class have a constructor in Java?
188.
Which two
methods is overridden by an Object, intended to be used as key in HashMap?
189.
What is
the difference between wait and sleep in Java?
190.
Difference
between List and Set in Java
191.
How do you
make a class Immutable in Java?
192.
Which data
type you should used to represent currency in Java?
193.
When to
use abstract class and interface in Java?
194.
Difference
between Hashtable and HashMap in Java?
195.
What is
the difference between ArrayList and LinkedList in Java?
196.
What is
the difference between Overloading and Overriding in Java
197.
What kind
of reference types are exists in Java?
198.
Difference
between checked and unchecked exception in Java?
199.
Does Java
array is an instance of Object?
200.
Does List<Number> can hold Integers? (Yes)
201.
Can we
pass ArrayList<Number> to a method which accepts List<Number> in Java? (Yes)
202.
Can we
pass ArrayList<Integer> to a method which accepts List<Number>?
203.
What is
volatile variable in Java?
204.
What is
the difference between CountDownLatch and CyclicBarrier in Java?
205.
Does BlockingQueue is thread-safe?
206.
Why wait and notify method should be called in
loop?
207.
What is the difference between "abc".equals(unknown
string) and unknown.equals("abc")?
208.
What is marker or tag interface in Java?
209.
What is the difference between Serializable and Externalizable interface
in Java?
210.
Can Enum types
implement interface in Java?
211.
Can Enum extend
a class in Java?
212.
How to prevent
your class from being subclassed?
213.
Can we override
Static method in Java? Compilation error?
214.
Which design
pattern have you used recently?
215.
What is the
difference between StringBuffer and StringBuilder in Java?
216.
What is the difference between Process and
Thread?
217.
What are the benefits of multi-threaded
programming?
218.
What is difference between user Thread and
daemon Thread?
219.
How can we create a Thread in Java?
220.
What are different states in lifecycle of
Thread?
221.
Can we call run() method of a Thread class?
222.
How can we pause the execution of a Thread
for specific time?
223.
What do you understand about Thread Priority?
224.
What is Thread Scheduler and Time Slicing?
225.
What is context-switching in multi-threading?
226.
How can we make sure main() is the last
thread to finish in Java Program?
227.
How does thread communicate with each other?
228.
Why thread communication methods wait(),
notify() and notifyAll() are in Object class?
229.
Why wait(), notify() and notifyAll() methods
have to be called from synchronized method or block?
230.
Why Thread sleep() and yield() methods are
static?
231.
How can we achieve thread safety in Java?
232.
What is volatile keyword in Java
233.
Which is more preferred – Synchronized method
or Synchronized block?
234.
How to create daemon thread in Java?
235.
What is ThreadLocal?
236.
What is Thread Group? Why it’s advised not to
use it?
237.
What is Java Thread Dump, How can we get Java
Thread dump of a Program?
238.
What is Deadlock? How to analyze and avoid
deadlock situation?
239.
What is Java Timer Class? How to schedule a
task to run after specific interval?
240.
What is Thread Pool? How can we create Thread
Pool in Java?
241.
What will happen if we don’t override Thread
class run()
242.
What is atomic operation? What are atomic
classes in Java Concurrency API?
243.
What is Executors Framework?
244.
What is BlockingQueue? How can we implement
Producer-Consumer problem using Blocking Queue?
245.
What is Callable and Future?
246.
What is FutureTask Class?
247.
What are Concurrent Collection Classes?
248.
What is Executors Class?
249.
What are some of the improvements in
Concurrency API in Java 8?
250.
What are Collection related features in Java
8?
251.
What is Java Collections Framework? List out
some benefits of Collections framework?
252.
What is the benefit of Generics in
Collections Framework?
253.
What are the basic interfaces of Java
Collections Framework?
254.
Why Collection doesn’t extend Cloneable and
Serializable interfaces?
255.
Why Map interface doesn’t extend Collection
interface?
256.
What is an Iterator?
257.
What is difference between Enumeration and
Iterator interface?
258.
Why there is not method like Iterator.add()
to add elements to the collection?
259.
Why Iterator don’t have a method to get next
element directly without moving the cursor?
260.
What is different between Iterator and
ListIterator?
261.
What are different ways to iterate over a
list?
262.
What do you understand by iterator fail-fast
property?
263.
What is difference between fail-fast and
fail-safe?
264.
How to avoid ConcurrentModificationException
while iterating a collection?
265.
Why there are no concrete implementations of
Iterator interface?
266.
What is UnsupportedOperationException?
267.
How HashMap works in Java?
268.
What is the importance of hashCode() and
equals() methods?
269.
Can we use any class as Map key?
270.
What are different Collection views provided
by Map interface?
271.
What is difference between HashMap and
Hashtable?
272.
How to decide between HashMap and TreeMap?
273.
What are similarities and difference between
ArrayList and Vector?
274.
What is difference between Array and
ArrayList? When will you use Array over ArrayList?
275.
What is difference between ArrayList and
LinkedList?
276.
Which collection classes provide random
access of it’s elements?
278.
Which collection classes are thread-safe?
279.
What are concurrent Collection Classes?
280.
What is BlockingQueue?
281.
What is Collections Class?
282.
What is Comparable and Comparator interface?
283.
What is difference between Comparable and
Comparator interface?
284.
How can we sort a list of Objects?
285.
While passing a Collection as argument to a
function, how can we make sure the function will not be able to modify it?
286.
How can we create a synchronized collection
from given collection?
287.
What are common algorithms implemented in
Collections Framework?
288.
What is Big-O notation? Give some examples?
289.
What are best practices related to Java
Collections Framework?
290.
What is Java Priority Queue?
291.
.
292.
Why can’t we write
code as List<Number> numbers = new
ArrayList<Integer>();
?
293.
Why can’t we create generic array? or write
code asList<Integer>[] array = new
ArrayList<Integer>[10];
294.
What is Exception in Java?
295.
What are the Exception Handling Keywords in
Java?
296.
Explain Java Exception Hierarchy?
297.
What are important methods of Java Exception
Class?
298.
Explain Java 7 ARM Feature and multi-catch
block?
299.
What is difference between Checked and
Unchecked Exception in Java?
300.
What is difference between throw and throws
keyword in Java?
301.
How to write custom exception in Java?
302.
What is OutOfMemoryError in Java?
303.
What are different scenarios causing
“Exception in thread main”?
304.
What is difference between final, finally and
finalize in Java?
305.
What happens when exception is thrown by main
method?
306.
Can we have an empty catch block?
307.
Provide some Java Exception Handling Best
Practices?