60+ Java Interview Questions for Quick Revision

Java Interviews are very different than traditional software developer interviews. You can clear a Java interview without even writing a single line of code, Yes, this is true, you can become a Java developer without someone asking you to write a function in Java interview. Though it's not the case everywhere and many companies are increasing including a coding test in their Java developer interview process, but there are many companies and start-ups where you can get a Java job without writing a single line of code. All you need to do is memorize those standard Java questions, which has been asked from ages and mostly test the theoretical knowledge of the candidate. This is great for candidates which lack hands-on coding experience, but sometimes this style of the interview can cost you good developers who are not good at interviews. Someone, who knows how to structure a complex program, knows how to model their class and objects, can write good, robust code but fail to answer questions like, Why String is Immutable? or How HashMap works in Java?

Since I have gone through a lot of such interviews and even conducted couple of them, I thought to compile a list of some of the most frequently asked Java interview questions, covering key topics like design patterns, design principles, OOP, JVM internals, Garbage collection, multithreading, generics and collections, XML parsing and others. This list is collection fo such questions. I have not answered them right here because I have already answered them in their individual post in this blog, you can visit the answer link to see the answer. 

Java Interview Questions for Freshers and Experienced

1) What is Composite design pattern?
2) Explain Liskov substitution principle?
3) Write a Java program to convert bytes to long?
4) What is false sharing in multithreading Java?
5) Can we make an array volatile in Java? What is the effect of making it volatile? (answer)
6) What is advantage and disadvantage of busy spin waiting strategy? (answer)
7) A difference between DOM and SAX parser in Java? (answer)
8) Write wait-notify code for producer-consumer problem? (solution)
9) Write code for thread-safe Singleton in Java? (answer)
10) What are 4 ways to iterate over Map in Java? Which one is best and why? (solution)

11) Write code to remove elements from ArrayList while iterating? (example)
12) is Swing thread-safe? (answer)
13) What is thread local variable in Java? (answer)
14) How do you convert a String to date in Java? (example)
15) Can we use String in the switch case? (Yes)
16) What is constructor chaining in Java? (answer)
17) Explain Java Heap space and Garbage collection? (answer)
18) Difference between major and minor GC? (answer)
19) Difference between -Xmx and -Xms JVM option? (answer)
20) How to check if a String contains only numeric digits? (regular expression)

21) Difference between poll() and remove() method of Queue in Java?
22) Difference between Comparator and Comparable in Java? (answer)
23) Why you need to override hashCode, when you override equals in Java? (answer)
24) How HashSet works internally in Java? (answer)
25) How do you print Array in Java? (answer)
26) Explain what 'path to root' means in the context of garbage collection. What are roots?
27) Write code for a simple implementation of HashMap/Hashtable
28) Write a short program to illustrate the concept of deadlock
29) Explain why recursive implementation of QuickSort will require O(log n) of additional space
30) Explain the design pattern used in Java and .NET io stream/reader APIs.

Java Interview Questions for Quick Revision

31) Create an Iterator filtering framework: an IObjectTest interface with a single boolean test(Object method and an Iterator sub-class which is initialized with another Iterator and an IObjectTest instance. Your iterator will then allow iteration over the original, but skipping any objects which don't pass the test. Create a simple unit test for this framework.
32) Difference between Abstract class and Interface - given a situation what would you choose between abstract class and interface? (answer)
33) Difference between inheritance and composition? (answer)
34) Difference between ArrayList and linked list? (answer)
35) Difference between sleep and wait? (answer)
36) Explain about HashMap (methods in HashMap and  the project in which we have used the HashMap more about equals() and hashCode()  (answer)
37) Explain the methods in Object class? (answer)
38) What is coupling? How do you reduce coupling and why?
39) Struts config file - can there be multiple configs? (answer)

40) Design patterns - factory, abstract factory, singleton implemented? (answer)
41) What does static, final mean, purposes; (answer)
42) How many accessibility modifiers exist? Please describe them. (answer)
43) Why do you need a main method? (answer)
44) How many constructors can you have?
45) Define overwriting and overloading? (answer)
46) Give java API implementations for overwriting and overloading
47) Describe the String class – unique properties (answer)
48) StringBuilder vs StringBuffer? differences? (answer)
49) Collections: please describe, give some examples and compare them to each other
50) ArrayList vs Vector? Differences, when to use which data structure? (answer)

51) HashMap vs Hashtable (answer)
52) What’s a tree in Java? How different is from the tree in data structure?
53) What’s a map? 
54) Multithreading: describe the thread management in Java?
55) What’s a semaphore? (answer)
56) How many states are there for threads?
57) Describe the usage for synchronized word (2)? (examples)
58) Serialization in java – a description and usage? (example)
59) Garbage collection in java – description and usage
61) Can you guarantee the garbage collection process? No
62) Singleton, please describe main features and coding (answer)
63) Factory. please describe main features and coding (answer)
64) Have you used others? please describe them?

What is the purpose of this list of  Java Interview questions?
The sole purpose is to conduct mock Java interviews by yourself. You can use this list to do last minute revision. Since answers are not provided, you can try answering them and if you can then you are ready to take on any telephonic round of Java interview or face-to-face round which doesn't involve coding.


  1. To be honest, if you want to find good Java developers ask more tougher questoins like :
    How do you find memory leak in Java application?
    How do you find which par tof your application/object is consuming most of your heap?
    What is pros and cons of 32-bit vs 64-bit JVM?
    How do you remote debug Tomcat or your own Java application?
    How do you find CPU and Memory usage of your application?
    Which Operating sytsem you deploy your Java applicaiton? If Linux then ask about some useful commands which will help in debugging e.g. nestat, ps, find, lsof, top etc

  2. Good questions, you can also check this huge list of Java interview questions for through preparation. It convers advanced topics like Concurrency, JVM internals, GC tuning, NIO and design patterns.

  3. its really good set of IQs but for beginners. Please post some for 5yrs+ exp


Feel free to comment, ask questions if you have any doubt.