Java Interview Preparation
Prepare for Java interviews — core concepts, OOP, collections, concurrency, Spring, and system design questions asked at top companies.
50 min•By Priygop Team•Last updated: Feb 2026
Core Java Interview Topics
- == vs equals(): == compares references (same object in memory), equals() compares values (content). Always override equals() with hashCode(). String uses value equality, objects default to reference
- HashMap Internals: Array of buckets, hash function determines bucket index. Collisions handled by linked list (Java 7) → balanced tree (Java 8, when > 8 entries in bucket). O(1) average lookup, O(log n) worst case
- Immutability: String, Integer, record classes are immutable — thread-safe without synchronization. Create immutable classes: private final fields, no setters, defensive copies in constructor
- Exception Handling: Checked (must handle: IOException) vs Unchecked (runtime: NullPointerException). Custom exceptions extend Exception (checked) or RuntimeException (unchecked). Never catch Exception/Throwable generically
- Generics: Type erasure — generic types removed at compile time (List<String> becomes List at runtime). Bounded types: <T extends Comparable<T>>. Wildcards: ? extends T (read), ? super T (write). PECS: Producer Extends, Consumer Super
- Java Memory Model: volatile ensures visibility (writes visible to all threads). synchronized ensures both visibility and atomicity. Happens-before relationship defines ordering guarantees between threads