Java Interview Preparation for 5 Years Experience
100 questions. Easy → Medium → Hard.
Five years into Java, the interview changes.
You are no longer expected to only answer “What is HashMap?”
You are expected to explain why it works, when it breaks, what trade-off you are making, and how you would debug it in production.
That is the purpose of this list.
This is not a random collection of 100 trivia questions. It is a progression:
Java fundamentals → OOP → Collections → Generics → Java 8+ → Concurrency → JVM → Modern Java → Production-level Java
If you can answer these 100 questions clearly, with examples from your own work, you have a strong Core/Advanced Java interview foundation for a 5-year backend role.
🎯 The companies you’re probably preparing for
This roadmap is designed around the kind of Java/backend preparation useful across service-based and product companies.
Below is the company set used throughout this guide. The logos are loaded as simple SVG icons so the section is visual on the website instead of being just a list of names.
How to read the company references: where a company is attached to an individual question, it means a public interview experience/report was found containing that topic or a closely related question. It is not an official company question bank, and interview loops vary by role, team, location and interviewer.
How to use this roadmap
Level 1 — Easy
Build the vocabulary and remove the “I know Java, but I can’t explain Java” problem.
Level 2 — Medium
Start connecting language features to collections, streams, concurrency and the JVM.
Level 3 — Hard
Stop memorising definitions. Think like an engineer who owns a production service.
For every question, try this four-step answer:
- Definition
- Example
- Trade-off / edge case
- Where I used it
At five years, step 4 is often what separates a memorised answer from an experienced answer.
🟢 Level 1 — Easy
Java Fundamentals
1. What is the difference between JDK, JRE, and JVM?
Topic: Java Fundamentals
Prepare from: Oracle Java platform docs
Interview lens: Java interview basics.
2. Why is Java platform independent? Explain the role of bytecode and the JVM.
Topic: Java Fundamentals
Prepare from: Oracle JVM specification
Interview lens: Java interview basics.
3. What is the difference between a class and an object?
Topic: Java Fundamentals
Prepare from: Dev.java OOP
Interview lens: OOP fundamentals.
4. What are encapsulation, inheritance, polymorphism, and abstraction? Give a practical Java example for each.
Topic: OOP
Prepare from: Dev.java classes and objects
Interview lens: OOP fundamentals.
5. What is the difference between method overloading and method overriding?
Topic: OOP
Prepare from: Dev.java inheritance
Interview lens: OOP fundamentals.
6. What is the difference between an abstract class and an interface?
Topic: OOP
Prepare from: Dev.java interfaces
Interview lens: OOP fundamentals.
7. Why does Java not support multiple inheritance through classes? How do interfaces address the diamond problem?
Topic: OOP
Company report: Morgan Stanley
Prepare from: Morgan Stanley / Java design report
Interview lens: OOP design.
8. What is the difference between == and equals() in Java?
Topic: Java Fundamentals
Company report: Adobe
Prepare from: Adobe report
Interview lens: Object equality.
9. What is the contract between equals() and hashCode()?
Topic: Java Fundamentals
Company report: Goldman Sachs
Prepare from: Goldman Sachs report
Interview lens: Object equality.
10. What is the difference between final, finally, and finalize()?
Topic: Java Fundamentals
Company report: Goldman Sachs
Prepare from: Goldman Sachs report
Interview lens: Language + lifecycle.
11. What are primitive types and wrapper classes? When would you use int versus Integer?
Topic: Java Fundamentals
Company report: Goldman Sachs
Prepare from: Goldman Sachs report
Interview lens: Types and boxing.
12. Why is String immutable in Java, and what benefits does that provide?
Topic: Strings
Company report: Goldman Sachs
Prepare from: Goldman Sachs report
Interview lens: Strings.
13. What is the difference between String, StringBuilder, and StringBuffer?
Topic: Strings
Prepare from: Java API docs
Interview lens: Strings.
14. What is autoboxing and unboxing? What pitfalls can it introduce?
Topic: Java Fundamentals
Company report: Walmart
Prepare from: Walmart report
Interview lens: Boxing.
15. Is Java pass-by-value or pass-by-reference? Explain with an object example.
Topic: Java Fundamentals
Prepare from: Java interview resource
Interview lens: Language semantics.
16. What is the difference between checked and unchecked exceptions?
Topic: Exceptions
Prepare from: Java exception docs
Interview lens: Exception handling.
17. What is the difference between throw and throws?
Topic: Exceptions
Prepare from: Java exception docs
Interview lens: Exception handling.
18. Can a finally block prevent an exception from propagating? What happens if finally itself throws?
Topic: Exceptions
Prepare from: Java exception docs
Interview lens: Exception handling.
19. What are static fields, static methods, and static initialization blocks?
Topic: OOP
Prepare from: Java language docs
Interview lens: Class members.
20. What is constructor chaining, and how do this() and super() work?
Topic: OOP
Prepare from: Java language docs
Interview lens: Constructors.
21. What is the difference between List, Set, Queue, and Map?
Topic: Collections
Prepare from: Oracle Collections Framework
Interview lens: Collections.
22. When would you choose ArrayList over LinkedList, and what are the practical trade-offs?
Topic: Collections
Prepare from: Oracle Collections Framework
Interview lens: Collections.
23. How does HashSet guarantee uniqueness?
Topic: Collections
Company report: Goldman Sachs
Prepare from: Goldman Sachs report
Interview lens: Collections.
24. How does HashMap work internally at a high level?
Topic: Collections
Company report: Goldman Sachs
Company report: Walmart
Prepare from: Goldman Sachs / Walmart reports
Interview lens: Collections.
25. What is the difference between HashMap, LinkedHashMap, and TreeMap?
Topic: Collections
Prepare from: Baeldung Collections Interview
Interview lens: Collections.
26. What is the difference between HashMap and Hashtable?
Topic: Collections
Prepare from: Oracle concurrent collections
Interview lens: Collections + concurrency.
27. What is ConcurrentHashMap, and when would you use it?
Topic: Collections
Prepare from: Oracle concurrent collections
Interview lens: Concurrent collections.
28. Why are Java generics invariant? Why is List not a subtype of List?
Topic: Generics
Prepare from: Java Generics docs
Interview lens: Generics.
29. What are bounded wildcards: ? extends T and ? super T? Explain PECS.
Topic: Generics
Prepare from: Java Generics docs
Interview lens: Generics.
30. What is type erasure, and what limitations does it create at runtime?
Topic: Generics
Prepare from: Java Generics docs
Interview lens: Generics.
🟡 Level 2 — Medium
Java 8+, Collections, Concurrency & JVM
31. What is a functional interface? Give examples from java.util.function.
Topic: Java 8+
Company report: Goldman Sachs
Prepare from: Goldman Sachs report
Interview lens: Functional programming.
32. What is a lambda expression, and how is it different from an anonymous class?
Topic: Java 8+
Prepare from: Dev.java Lambda Expressions
Interview lens: Functional programming.
33. What is a method reference? When does it improve readability?
Topic: Java 8+
Prepare from: Dev.java Method References
Interview lens: Functional programming.
34. What is the difference between map() and flatMap() in streams?
Topic: Java 8+
Prepare from: Java Streams docs
Interview lens: Streams.
35. What is the difference between intermediate and terminal stream operations?
Topic: Java 8+
Prepare from: Java Streams docs
Interview lens: Streams.
36. What does lazy evaluation mean in the Stream API?
Topic: Java 8+
Prepare from: Java Streams docs
Interview lens: Streams.
37. When should you avoid parallelStream()?
Topic: Java 8+
Prepare from: Java Streams docs
Interview lens: Streams + concurrency.
38. What problem does Optional solve, and where should you avoid using it?
Topic: Java 8+
Company report: Goldman Sachs
Prepare from: Goldman Sachs report
Interview lens: Optional.
39. What is the difference between orElse() and orElseGet() in Optional?
Topic: Java 8+
Company report: Goldman Sachs
Prepare from: Goldman Sachs interview resource
Interview lens: Optional.
40. What are default and static methods in interfaces, and why were they introduced?
Topic: Java 8+
Company report: Goldman Sachs
Prepare from: Goldman Sachs report
Interview lens: Interfaces.
41. Why was java.time introduced? Compare it with the older Date/Calendar APIs.
Topic: Date/Time
Prepare from: Java time API docs
Interview lens: Date and time.
42. What is the difference between Comparable and Comparator?
Topic: Collections
Company report: Goldman Sachs
Prepare from: Goldman Sachs report
Interview lens: Sorting.
43. How does PriorityQueue work, and what does its ordering guarantee actually mean?
Topic: Collections
Company report: Goldman Sachs
Prepare from: Goldman Sachs report
Interview lens: Heaps + collections.
44. What is fail-fast iteration? Why can an iterator throw ConcurrentModificationException?
Topic: Collections
Prepare from: Oracle Collections Framework
Interview lens: Collections.
45. What is the difference between Collections.synchronizedMap() and ConcurrentHashMap?
Topic: Collections
Prepare from: Oracle concurrent collections
Interview lens: Concurrency.
46. What is the difference between Thread, Runnable, and Callable?
Topic: Concurrency
Company report: Walmart
Company report: Goldman Sachs
Prepare from: Walmart / Goldman reports
Interview lens: Concurrency.
47. What is the difference between start() and run() on a Thread?
Topic: Concurrency
Company report: Goldman Sachs
Prepare from: Goldman Sachs report
Interview lens: Concurrency.
48. What are the lifecycle states of a Java thread?
Topic: Concurrency
Prepare from: Java concurrency docs
Interview lens: Concurrency.
49. What does synchronized guarantee? Explain mutual exclusion and visibility.
Topic: Concurrency
Prepare from: Java concurrency docs
Interview lens: Concurrency.
50. What is volatile? Why does volatile not make i++ atomic?
Topic: Concurrency
Company report: Walmart
Company report: Goldman Sachs
Prepare from: Walmart / Goldman reports
Interview lens: Java Memory Model.
51. What is the difference between synchronized and volatile?
Topic: Concurrency
Company report: Goldman Sachs
Prepare from: Goldman Sachs report
Interview lens: Java Memory Model.
52. What are wait(), notify(), and notifyAll(), and what object-monitor rules apply?
Topic: Concurrency
Prepare from: Oracle synchronization tutorial
Interview lens: Concurrency.
53. What is the difference between sleep(), wait(), and join()?
Topic: Concurrency
Prepare from: Java concurrency docs
Interview lens: Concurrency.
54. What is ExecutorService, and why is a thread pool preferable to creating unlimited threads?
Topic: Concurrency
Company report: Walmart
Prepare from: Walmart report
Interview lens: Executors.
55. What is the difference between submit() and execute() on an ExecutorService?
Topic: Concurrency
Prepare from: Java concurrency docs
Interview lens: Executors.
56. What is Future, and what limitations does CompletableFuture address?
Topic: Concurrency
Company report: Walmart
Prepare from: Walmart report
Interview lens: Async programming.
57. How do thenApply(), thenCompose(), and thenCombine() differ in CompletableFuture?
Topic: Concurrency
Prepare from: Java CompletableFuture docs
Interview lens: Async programming.
58. What is a race condition? Give a Java example and two ways to prevent it.
Topic: Concurrency
Prepare from: Java concurrency docs
Interview lens: Concurrency.
59. What is deadlock? How would you diagnose and prevent it?
Topic: Concurrency
Prepare from: Java concurrency docs
Interview lens: Concurrency.
60. What are AtomicInteger and CAS, and when are atomic variables useful?
Topic: Concurrency
Prepare from: Java concurrency docs
Interview lens: Lock-free concurrency.
61. What is ThreadLocal, and what problems can it cause in thread pools?
Topic: Concurrency
Prepare from: Java concurrency docs
Interview lens: Concurrency.
62. What are the main runtime memory areas in the JVM?
Topic: JVM
Prepare from: Oracle JVM specification
Interview lens: JVM.
63. What is the difference between stack memory and heap memory?
Topic: JVM
Company report: Walmart
Prepare from: Walmart interview report
Interview lens: JVM.
64. What is garbage collection, and why can Java still suffer from memory leaks?
Topic: JVM
Company report: Walmart
Prepare from: Walmart report
Interview lens: JVM + GC.
65. What is a Stop-The-World pause?
Topic: JVM
Prepare from: Java interview resource
Interview lens: JVM + GC.
66. What is a class loader? Explain the parent delegation model.
Topic: JVM
Prepare from: Java class loading docs
Interview lens: JVM.
67. What is reflection, and why is it considered a runtime mechanism?
Topic: JVM
Company report: Goldman Sachs
Prepare from: Goldman Sachs report
Interview lens: Reflection.
68. What is the difference between compile-time, runtime, and JIT optimization?
Topic: JVM
Prepare from: Java HotSpot docs
Interview lens: JVM.
69. What is JIT compilation, and why doesn’t the JVM simply interpret everything?
Topic: JVM
Prepare from: Java HotSpot docs
Interview lens: JVM.
70. What is escape analysis, and how can it affect object allocation?
Topic: JVM
Prepare from: HotSpot docs
Interview lens: JVM performance.
🔴 Level 3 — Hard
JVM Internals, Modern Java & Production Thinking
71. What tools would you use to investigate high CPU, high heap usage, or frequent GC in a Java service?
Topic: JVM
Prepare from: JDK Mission Control / JFR docs
Interview lens: JVM troubleshooting.
72. What is the Java Platform Module System, and what problem does it solve?
Topic: Java 9+
Prepare from: Java modules docs
Interview lens: Modules.
73. What are records? What guarantees do they provide, and when should you not use them?
Topic: Java 14+
Prepare from: Java records docs
Interview lens: Modern Java.
74. What are sealed classes and interfaces, and how do they constrain inheritance?
Topic: Java 17+
Prepare from: Java sealed classes docs
Interview lens: Modern Java.
75. What are virtual threads, and when are they a good fit compared with platform threads?
Topic: Java 21+
Prepare from: Java virtual threads docs
Interview lens: Modern concurrency.
76. Explain the Java Memory Model’s happens-before relationship with a practical example.
Topic: Concurrency
Prepare from: Oracle concurrency docs
Interview lens: JMM.
77. Why can double-checked locking be broken without volatile?
Topic: Concurrency
Company report: Goldman Sachs
Prepare from: Goldman Sachs report
Interview lens: JMM + singleton.
78. How would you implement a thread-safe Singleton, and what are the trade-offs of enum versus lazy initialization?
Topic: Concurrency
Company report: Goldman Sachs
Company report: Walmart
Prepare from: Goldman Sachs / Walmart reports
Interview lens: Design + concurrency.
79. How would you make a Singleton resistant to reflection and serialization attacks?
Topic: Design
Company report: Goldman Sachs
Prepare from: Goldman Sachs report
Interview lens: Design + reflection.
80. What is Java serialization, and what are the risks of using Serializable in modern services?
Topic: Serialization
Prepare from: Java serialization docs
Interview lens: Serialization.
81. What is serialVersionUID, and when does deserialization fail because of class-version changes?
Topic: Serialization
Prepare from: Java serialization docs
Interview lens: Serialization.
82. When would you use Java NIO channels and buffers instead of classic streams?
Topic: NIO
Prepare from: Java NIO docs
Interview lens: I/O.
83. How would you process a multi-gigabyte file in Java without loading it entirely into memory?
Topic: I/O
Company report: Goldman Sachs
Prepare from: Goldman Sachs interview report
Interview lens: I/O + performance.
84. How would you find and reduce allocation pressure in a high-throughput Java service?
Topic: Performance
Prepare from: JDK Flight Recorder docs
Interview lens: Performance.
85. What is object pooling, and why can pooling ordinary Java objects sometimes make performance worse?
Topic: Performance
Prepare from: JVM performance
Interview lens: Performance.
86. What makes a stream pipeline safe or unsafe for parallel execution?
Topic: Streams
Prepare from: Java Streams docs
Interview lens: Streams + concurrency.
87. Why can shared mutable state inside a parallel stream produce incorrect results?
Topic: Streams
Prepare from: Java Streams docs
Interview lens: Streams + concurrency.
88. How would you design a custom immutable value object that is safe as a HashMap key?
Topic: Collections
Company report: Goldman Sachs
Prepare from: Goldman Sachs interview report
Interview lens: Immutability.
89. What is dynamic dispatch in Java, and how does it determine an overridden method at runtime?
Topic: Language
Company report: Walmart
Prepare from: Walmart report
Interview lens: OOP + JVM.
90. Explain upcasting and downcasting. When can a downcast fail at runtime?
Topic: Language
Company report: Adobe
Prepare from: Adobe report
Interview lens: Type system.
91. How would you design exception handling for a library so callers can recover without losing the root cause?
Topic: Exceptions
Prepare from: Java exception docs
Interview lens: Exception design.
92. How would you design a bounded producer-consumer pipeline using BlockingQueue?
Topic: Concurrency
Prepare from: Oracle concurrent collections
Interview lens: Concurrency.
93. When would you choose ReentrantLock over synchronized? Discuss fairness, tryLock, interruptibility, and conditions.
Topic: Concurrency
Prepare from: Java locks docs
Interview lens: Concurrency.
94. What is a Semaphore, and where would it be useful in a Java backend service?
Topic: Concurrency
Prepare from: Oracle concurrency docs
Interview lens: Concurrency.
95. How would you diagnose a deadlock in production using thread dumps?
Topic: Concurrency
Prepare from: JDK troubleshooting tools
Interview lens: JVM troubleshooting.
96. A Java API suddenly has 10x more concurrent requests. What JVM, thread-pool, GC, and application-level signals would you inspect first?
Topic: Architecture
Company report: Walmart
Prepare from: Walmart / Java interview reports
Interview lens: Production Java.
97. How would you design a thread-safe in-memory cache in Java, including eviction, concurrency, and memory considerations?
Topic: Design
Company report: Walmart
Prepare from: Walmart LLD report
Interview lens: Advanced Java design.
98. Which Java 8–21 features have materially improved backend code, and which ones should you avoid adopting just for novelty?
Topic: Modern Java
Prepare from: Java language evolution docs
Interview lens: Modern Java judgment.
99. At five years of experience, how would you explain a Java decision from your production project: the problem, alternatives, trade-off, failure mode, and measurable outcome?
Topic: Interview Strategy
Prepare from: Interview preparation
Interview lens: Senior interview communication.
100. How do load factor, threshold, and resizing affect HashMap performance and memory usage?
Topic: Collections
Prepare from: Oracle HashMap API
Interview lens: HashMap internals.
🧭 The 100-question map
| Stage | Questions | What you should be able to do |
|---|---|---|
| 🟢 Easy | 1–30 | Explain Java fundamentals without hesitation |
| 🟡 Medium | 31–70 | Reason about Java APIs, concurrency and the JVM |
| 🔴 Hard | 71–100 | Discuss internals, trade-offs and production scenarios |
📚 Core resources
Official Java
- Dev.java — Learn Java
- Java SE API Documentation
- Java Language Specification
- Java Virtual Machine Specification
Interview practice
- LeetCode — Java Interview Questions
- Baeldung — Java Collections Interview Questions
- Baeldung — Java Concurrency Interview Questions
Company-report evidence used for tags
- Goldman Sachs — Java Associate interview report
- Goldman Sachs — Java/Spring interview experience
- Walmart — Software Engineer III Java Backend interview
- Walmart — SSE Java/LLD interview
- Adobe — Software Developer interview
- JPMorgan Chase — 4.4 years Java interview experience
- Morgan Stanley — Java design principles interview discussion
Final advice for a 5-year Java engineer
Don’t try to finish all 100 in one weekend.
A better approach is:
10 questions → write your own answer → code the tricky ones → connect them to a project → repeat.
And when an interviewer asks:
“What is volatile?”
don’t stop at:
“It provides visibility.”
Go one level deeper:
visibility → happens-before → why i++ is still not atomic → when you’d use AtomicInteger → where this matters in a real service.
That is the difference between preparing for a Java interview and preparing to own Java code in production.
One last rule
Never memorise an interview answer you cannot explain with code.
If you can explain it, demonstrate it, discuss its trade-offs, and connect it to production — you’re ready.
100 questions. One language. Five years of experience. Now go from syntax to systems.
Styling for the company logo section
Add this to src/styles/global.css:
.company-logos {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 1rem;
margin: 2rem 0 3rem;
}
.company-logos a {
display: flex;
align-items: center;
gap: 0.75rem;
padding: 1rem;
border: 1px solid #ddd;
text-decoration: none;
color: inherit;
background: #fff;
transition: transform 0.15s ease, border-color 0.15s ease;
}
.company-logos a:hover {
transform: translateY(-2px);
border-color: #999;
}
.company-logos img {
width: 42px;
height: 42px;
object-fit: contain;
flex-shrink: 0;
}
.company-logos span {
font-weight: 600;
}
@media (max-width: 800px) {
.company-logos {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}
@media (max-width: 480px) {
.company-logos {
grid-template-columns: 1fr;
}
}
Note: the logo images above are external SVG assets. If you want the site to remain fully self-contained later, download the SVGs into
public/company-logos/and point the<img>tags to local files.
Comments