Most Asked Java Questions
Most Asked Java Questions
2. Explain the contract between equals() and hashCode(). What happens if you break it?
3. Why is String immutable in Java? What are the benefits and drawbacks?
6. Explain Java Memory Model (JVM, Heap, Stack, Method Area, PC Register)
7. What are the different types of garbage collectors in Java? Explain G1GC.
8. What is memory leak in Java? How can you identify and prevent it?
10. Explain the concept of deadlock. How can you prevent it?
11. What is the difference between wait(), sleep(), and yield() methods?
12. Explain volatile keyword. When and why would you use it?
19. Can you have multiple inheritance in Java? How do you achieve it?
📊 COLLECTIONS FRAMEWORK
26. What is the difference between ArrayList and LinkedList? When to use which?
36. Explain reflection in Java. What are its use cases and drawbacks?
🚨 EXCEPTION HANDLING
42. Difference between checked and unchecked exceptions.
44. Can you have multiple catch blocks? Explain exception hierarchy.
45. What happens if you put return statement in try, catch, and finally blocks?
50. What are different types of references in Java (Strong, Weak, Soft, Phantom)?
52. How do you tune JVM performance? What are important JVM parameters?
🔍 BONUS QUESTIONS
53. What is the difference between deep copy and shallow copy?