JAVA INTERVIEW REVISION HANDBOOK
Structured for 3+ Years Java Developer Interviews
JAVA BASICS
JDK vs JRE vs JVM
Q. Explain difference between JDK, JRE and JVM
JVM executes bytecode and provides platform independence.
JRE contains JVM + libraries required to run Java apps.
JDK contains JRE + development tools like javac, jstack, jmap.
String Pool
Q. What is String Pool and why String is immutable?
String pool reuses literals to save memory.
String is immutable for security, thread safety and caching.
Immutable objects are safe for HashMap keys.
OOP CONCEPTS
Abstraction vs Encapsulation
Q. Difference between abstraction and encapsulation
Abstraction hides implementation details.
Encapsulation hides internal data using access modifiers.
Abstraction focuses on WHAT, encapsulation focuses on HOW.
Composition vs Inheritance
Q. When should composition be preferred over inheritance?
Composition provides loose coupling.
Inheritance creates tight dependency.
Prefer composition unless there is strong IS-A relationship.
COLLECTIONS FRAMEWORK
HashMap Internals
Q. Explain internal working of HashMap
Uses array of buckets.
Index calculated using hashCode.
Collision handled using linked list/tree.
Java 8 converts bucket to Red-Black tree after threshold 8.
Map<Integer, String> map = new HashMap<>();
[Link](1, "Java");
[Link]([Link](1));
ConcurrentHashMap
Q. How ConcurrentHashMap achieves thread safety?
Uses bucket level locking.
Allows concurrent reads/writes.
More efficient than Hashtable.
Map<Integer, String> map = new HashMap<>();
[Link](1, "Java");
[Link]([Link](1));
MULTITHREADING & CONCURRENCY
synchronized vs Lock
Q. Difference between synchronized and ReentrantLock
synchronized is keyword level locking.
ReentrantLock provides tryLock(), fairness and interruptibility.
Lock gives more flexibility.
CompletableFuture
Q. Why CompletableFuture is preferred over Future?
Supports async chaining.
Non-blocking programming.
Supports callbacks and parallel execution.
[Link](() -> fetchData())
.thenApply(data -> process(data))
.thenAccept([Link]::println);
JAVA 8+
Streams
Q. Difference between map() and flatMap()
map transforms one object to another.
flatMap flattens nested structures.
Used heavily in stream processing.
List<String> names = [Link]()
.filter(x -> [Link]("A"))
.map(String::toUpperCase)
.collect([Link]());
Functional Interfaces
Q. Common built-in functional interfaces
Predicate -> boolean check
Function -> transform
Consumer -> consume object
Supplier -> provide object
JVM & MEMORY
Heap vs Stack
Q. Difference between Heap and Stack memory
Heap stores objects.
Stack stores method calls and local variables.
Heap managed by GC automatically.
Garbage Collection
Q. Explain G1GC and Stop-The-World
G1GC divides heap into regions.
Improves pause time management.
Stop-The-World pauses all application threads during GC.
ADVANCED JAVA
Reflection
Q. What is reflection and where is it used?
Used to inspect classes at runtime.
Frameworks like Spring/Hibernate use reflection.
Slower than direct method calls.
Design Patterns
Q. Most asked design patterns in interviews
Singleton
Factory
Builder
Strategy
Observer
MOST ASKED RECENT INTERVIEW QUESTIONS
Production Issue
Q. Tell me about a production issue you solved
Explain root cause.
Mention logs/debugging approach.
Explain optimization/fix and impact.
Performance
Q. How did you optimize API/database performance?
Indexing
Caching
Pagination
Reducing DB calls
Async processing
FINAL REVISION CHECKLIST
Collections internals
Java 8 streams and lambdas
Concurrency and thread safety
ExecutorService and CompletableFuture
JVM memory and GC
HashMap internals
Exception handling
Design patterns
Real project scenarios
Performance optimization