Java interviews blend language fundamentals, OOP design, collections, concurrency basics, and framework awareness (often Spring). Explain trade-offs clearly—interviewers care more about reasoning than trivia.
Core topics to rehearse
- JVM, bytecode, JDK vs JRE, garbage collection at a high level
- OOP pillars, equals/hashCode, interfaces vs abstract classes
- Collections complexity, HashMap internals (buckets, load factor)
- Exceptions: checked vs unchecked, try-with-resources
- Concurrency keywords:
synchronized,volatile, thread pools overview - Spring Boot: DI, REST controllers, application context (conceptual)
Whiteboard patterns
Implement simple APIs: reverse a string, detect duplicates, design a LRU cache sketch, explain REST login with JWT or session. Tie answers to production: validation, logging, tests.
Important interview questions and answers
- Q: ArrayList vs LinkedList?
A: ArrayList default for lists; LinkedList rarely wins except specific deque operations. - Q: How does HashMap handle collisions?
A: Chaining (and trees in Java 8+ when buckets grow)—equals/hashCode contract critical. - Q: String immutability benefits?
A: Thread safety, string pool, secure class loading, stable hash codes.
Self-check
- Can you explain equals and hashCode in one minute?
- What is dependency injection in plain language?
Interview prep
- Must-know Java interview topics?
JVM basics, OOP, collections and complexity, equals/hashCode, exceptions, concurrency overview, JDBC/Spring concepts—explain trade-offs with examples.