Java
Collections, multi-threading, memory, streams, exceptions, SOLID & comprehensive Java library
Prepare for Java interviews with 125+ topics covering collections framework, multi-threading and concurrency, JVM memory management, functional programming with streams, exception handling, SOLID principles, and a comprehensive Java library with OOP concepts, modern Java features (records, sealed classes, virtual threads, pattern matching), generics, I/O, date/time API, design patterns, advanced concurrency, and more. Each topic includes a clear explanation, real-world analogy, code examples, and common pitfalls interviewers look for.
Collections 4 topics
ArrayList vs LinkedList
Pick the list backed by an array (fast random access) or by a doubly-linked list (fast insert/remove at known nodes).
HashMap Internals
Understand the bucket array, hash collisions, and the treeify threshold so you can reason about HashMap performance.
ConcurrentHashMap
A thread-safe Map with concurrent reads and finely-grained writes — without locking the entire map.
Comparable vs Comparator
Define an object's natural order once (Comparable) or supply an alternate ordering on demand (Comparator).
Multi Threading 5 topics
Thread Lifecycle
Know the six states a Java thread moves through, and what causes each transition.
synchronized vs volatile
Pick the minimal tool — mutual exclusion (synchronized) vs visibility-only (volatile) — for the concurrency problem you actually have.
ExecutorService & Thread Pools
Run tasks on a managed thread pool instead of spawning raw threads — bounded resources, reuse, and proper shutdown.
CompletableFuture
Compose asynchronous computations into pipelines — like Promises in JavaScript — without blocking on every step.
Locks & Synchronizers
Use explicit locks (ReentrantLock, ReadWriteLock) and synchronizers (Semaphore, CountDownLatch, CyclicBarrier) when synchronized isn't enough.
Memory Management 4 topics
JVM Memory Areas
Understand where Java puts objects (heap), call frames (stack), and class metadata (metaspace) so you can diagnose OOMs.
Garbage Collection
Free heap memory automatically by identifying objects no longer reachable from GC roots — and choose the GC algorithm that fits your latency vs throughput target.
Memory Leaks & Reference Types
Recognize how unintended references prevent GC, and use Strong / Soft / Weak / Phantom references to control object lifetime.
Class Loaders
Load .class bytecode into the JVM on demand, organized in a parent-delegation hierarchy.
Streams 4 topics
Stream Pipelines
Declarative pipelines for processing data — filter, map, reduce — that read like a description of what you want, not how to loop.
Collectors
Build results from a stream — list, set, map, grouping, summary stats — using ready-made collector factories.
Parallel Streams
Switch a stream pipeline to run in parallel on the common ForkJoinPool — for CPU-bound work over large data.
Optional
Express "value or absence" in the type system instead of returning null — making missing-value handling explicit.
Exceptions 3 topics
Checked vs Unchecked Exceptions
Choose between forcing callers to handle a failure (checked) and letting them propagate it (unchecked).
try-with-resources
Auto-close anything that implements AutoCloseable — guaranteed cleanup even on exceptions, no boilerplate finally.
Custom Exceptions & Chaining
Define domain-specific exception types and preserve the original cause when wrapping lower-level failures.
SOLID 5 topics
Single Responsibility Principle (SRP)
A class should have one, and only one, reason to change.
Open/Closed Principle (OCP)
Software entities should be open for extension, but closed for modification.
Liskov Substitution Principle (LSP)
Subtypes must be substitutable for their base types without altering correctness.
Interface Segregation Principle (ISP)
Clients should not be forced to depend on methods they do not use.
Dependency Inversion Principle (DIP)
High-level modules should not depend on low-level modules. Both should depend on abstractions.
Library 100 topics
Encapsulation in Java
Hide internal state behind access modifiers and expose behavior through public methods.
Inheritance & Method Resolution
Understand how Java resolves which method to call when classes form an inheritance hierarchy.
Polymorphism: Compile-Time & Runtime
Distinguish between static (overloading) and dynamic (overriding) polymorphism and know when each applies.
Abstraction in Java
Use abstract classes and interfaces to define contracts without exposing implementation.
Abstract Classes vs Interfaces
Know exactly when to choose an abstract class over an interface — a top-5 Java interview question.
Method Overloading Rules
Know the exact rules Java uses to resolve overloaded methods and the common pitfalls with autoboxing and varargs.
Method Overriding & @Override
Understand the rules for valid overrides and why @Override is non-negotiable.
Composition over Inheritance
Know why delegation through composition is usually better than extending a class.
Object Class Methods
Know every method in java.lang.Object and when to override each one.
Access Modifiers
Understand the four access levels in Java and their scope: private, default, protected, public.
The static Keyword
Know every use of static in Java: fields, methods, blocks, nested classes, and imports.
The final Keyword
Know every use of final: variables, methods, classes, and how it affects immutability and performance.
The this & super Keywords
Know every use of this and super: field access, constructor chaining, method calls, and passing the current instance.
Initialization Blocks: Static & Instance
Understand the order of execution of static blocks, instance blocks, constructors, and field initializers.
Variable Scoping & Shadowing
Know how Java resolves variable names when local, instance, and class-level variables share the same name.
Primitive Types & Wrapper Classes
Know all 8 primitives, their sizes, default values, and the corresponding wrapper classes.
Autoboxing & Unboxing Pitfalls
Know when Java automatically converts between primitives and wrappers, and the performance and correctness traps.
Type Casting: Widening & Narrowing
Know when Java casts automatically (widening), when you must cast explicitly (narrowing), and the data loss risks.
String Immutability & String Pool
Understand why Strings are immutable, how the String Pool works, and the performance implications.
StringBuilder vs StringBuffer
Know the difference, when to use each, and why StringBuilder replaced StringBuffer in modern code.
equals() & hashCode() Contract
Understand the contract between equals and hashCode, and what breaks when you violate it.
Generics Fundamentals
Understand type parameters, type safety at compile time, and why generics exist.
Type Erasure
Understand how generics are implemented via erasure and the limitations this creates.
Bounded Type Parameters & Wildcards
Know the difference between <T extends X>, <? extends X>, <? super X>, and PECS (Producer Extends, Consumer Super).
Enums & Enum Methods
Use enums as type-safe constants with behavior — fields, methods, abstract methods, and implementing interfaces.
Annotations & Custom Annotations
Understand built-in annotations, create custom ones, and know the retention policies.
Varargs & Heap Pollution
Understand variable-length arguments, their array backing, and the safety concerns with generic varargs.
Pass by Value in Java
Java is ALWAYS pass by value — understand what this means for primitives and objects.
Inner Classes: Static, Member, Local, Anonymous
Know the four types of inner classes, when each is appropriate, and their relationship to the enclosing instance.
Lambda Expressions
Write concise function literals and understand how they relate to functional interfaces, closures, and anonymous classes.
Method References
Use the four types of method references as shorthand for lambdas that call a single existing method.
Functional Interfaces
Know the key functional interfaces in java.util.function and how to compose them.
Default & Static Methods in Interfaces
Understand why Java 8 added default methods, how they enable interface evolution, and resolution rules for conflicts.
Marker Interfaces
Understand Serializable, Cloneable, and the marker interface pattern — and when annotations replaced it.
Records (Java 14+)
Use records for immutable data carriers with auto-generated equals, hashCode, toString, and accessors.
Sealed Classes & Interfaces (Java 17)
Restrict which classes can extend a type — enabling exhaustive pattern matching and controlled hierarchies.
Pattern Matching for instanceof (Java 16)
Eliminate explicit casts after instanceof checks using pattern variables.
Switch Expressions & Pattern Matching
Use modern switch as an expression with arrow syntax, pattern matching, and guarded patterns.
Text Blocks (Java 15)
Write multi-line string literals with natural formatting using triple-quote syntax.
Local Variable Type Inference (var)
Use var for local variables where the type is obvious, and know when NOT to use it.
Virtual Threads (Java 21)
Use lightweight virtual threads for high-concurrency I/O workloads without the overhead of platform threads.
Java Platform Module System (JPMS)
Understand Java modules: module-info.java, exports, requires, and strong encapsulation.
Cloning: Shallow vs Deep Copy
Understand Object.clone(), its problems, and the preferred alternatives (copy constructors, factory methods).
Serialization & Deserialization
Understand Java's built-in serialization, serialVersionUID, transient, and the security concerns.
Reflection API
Inspect and modify class structure, fields, methods, and constructors at runtime — and know the costs.
Java I/O Streams: Byte vs Character
Distinguish InputStream/OutputStream (bytes) from Reader/Writer (characters) and know when to use each.
NIO.2 Path & Files API
Use the modern file system API (Path, Files) introduced in Java 7 for file operations.
The transient Keyword
Exclude fields from Java serialization and understand its interaction with default values.
LocalDate, LocalTime & LocalDateTime
Use the modern date/time API (Java 8+) that replaced the broken Date/Calendar classes.
Regular Expressions in Java
Use Pattern and Matcher for regex operations and know the performance implications of compiled vs inline patterns.
Iterator, ListIterator & Spliterator
Understand the three iteration interfaces, their capabilities, and when Spliterator enables parallel processing.
Fail-Fast vs Fail-Safe Iterators
Understand why ArrayList throws ConcurrentModificationException but ConcurrentHashMap doesn't.
TreeMap, TreeSet & Natural Ordering
Use sorted collections backed by Red-Black trees and understand Comparable vs Comparator in this context.
PriorityQueue & Deque
Use priority-based and double-ended queue implementations for scheduling, BFS, and stack/queue patterns.
LinkedHashMap & LRU Cache
Use insertion-order or access-order LinkedHashMap, and build an LRU cache with it.
Atomic Classes & CAS Operations
Use lock-free thread-safe operations on single variables with AtomicInteger, AtomicReference, and compare-and-swap.
ThreadLocal & InheritableThreadLocal
Store per-thread data without synchronization and understand the memory leak risk.
Fork/Join Framework
Divide computational tasks into subtasks recursively and process them in parallel with work-stealing.
BlockingQueue Implementations
Choose the right BlockingQueue for producer-consumer patterns: ArrayBlockingQueue, LinkedBlockingQueue, or SynchronousQueue.
CopyOnWrite Collections
Use CopyOnWriteArrayList and CopyOnWriteArraySet for read-heavy, write-rare thread-safe scenarios.
JVM Memory Model & Garbage Collection
Understand heap structure, GC generations, and how different collectors affect application latency.
String Pool & String Internment
Understand how Java optimizes String storage with the string pool and when intern() matters.
ClassLoader Hierarchy
Understand how Java loads classes, the delegation model, and when custom classloaders are needed.
Custom Annotations & Annotation Processing
Create and process custom annotations, understand retention policies, and use annotation processors for compile-time code generation.
try-with-resources & AutoCloseable
Automatically close resources (streams, connections, locks) and avoid resource leaks using the try-with-resources statement.
Exception Hierarchy & Handling Strategy
Navigate the exception hierarchy, choose between checked and unchecked, and adopt modern exception handling patterns.
JDBC Basics & PreparedStatement
Connect to databases, execute queries safely with PreparedStatements, and manage transactions.
Properties & Configuration Loading
Load configuration from .properties files, system properties, and environment variables in the right order.
Builder Pattern in Java
Construct complex objects step-by-step with a fluent API, and understand where Lombok's @Builder fits.
Singleton Pattern & Thread Safety
Implement thread-safe singletons correctly, and know why the double-checked locking idiom requires volatile.
Strategy Pattern with Functional Interfaces
Replace class-based strategy implementations with lambdas and functional interfaces for cleaner code.
Observer Pattern & Event Handling
Implement publish-subscribe in Java using listeners, PropertyChangeSupport, or modern reactive alternatives.
Decorator Pattern & I/O Streams
Understand how Java I/O streams use the Decorator pattern and how to apply it in your own designs.
Proxy Pattern & Dynamic Proxies
Use java.lang.reflect.Proxy for runtime interface implementation and understand how frameworks use it.
Immutability in Java
Design immutable classes correctly and understand their benefits for thread safety and defensive programming.
Factory Method & Abstract Factory
Use factory patterns to decouple object creation from usage, and recognize them in JDK APIs.
Weak, Soft & Phantom References
Understand Java reference types for memory-sensitive caching and resource cleanup without finalize().
Comparable, Comparator & Fluent Sorting
Define natural ordering with Comparable, build custom orderings with Comparator's fluent API, and use null-safe comparisons.
HashMap Internals: Hashing, Buckets & Treeification
Understand how HashMap works internally — hashing, collision handling, and the Java 8 treeification optimization.
EnumSet & EnumMap
Use specialized, high-performance collections for enum keys/elements instead of HashSet/HashMap.
Text Blocks & String Templates
Write multi-line strings cleanly with text blocks and understand the coming String templates feature.
Collections.unmodifiable* vs List.of() vs List.copyOf()
Choose the right unmodifiable/immutable collection factory and understand the differences in mutability guarantees.
Method References & Four Types
Use method references as concise alternatives to lambdas, master all four types, and know when lambdas are clearer.
Functional Interfaces & @FunctionalInterface
Understand the core functional interfaces (Predicate, Function, Consumer, Supplier) and create custom ones.
CompletableFuture for Async Programming
Compose asynchronous operations with CompletableFuture's fluent API instead of blocking with Future.get().
Generics & Type Erasure
Understand how Java generics work at compile time, why they're erased at runtime, and common pitfalls.
Garbage Collection Roots & Memory Leaks
Identify GC roots, understand why objects aren't collected, and diagnose common Java memory leaks.
Java Streams: Intermediate vs Terminal Operations
Distinguish lazy intermediate operations from eager terminal operations and understand stream pipeline evaluation.
Collectors: toMap, groupingBy, partitioningBy
Master the essential Collectors for stream terminal operations and avoid common pitfalls with toMap.
Shutdown Hooks & Graceful Termination
Register cleanup logic for JVM shutdown and design applications for graceful termination.
ServiceLoader & SPI (Service Provider Interface)
Use Java's built-in plugin mechanism to discover and load implementations at runtime.
Varargs & SafeVarargs
Use variable-length arguments safely and understand heap pollution warnings with generic varargs.
Static & Instance Initializer Blocks
Understand when and why to use static initializers, instance initializers, and their execution order.
Covariant Return Types & Bridge Methods
Understand method overriding with narrower return types and the invisible bridge methods the compiler generates.
The volatile Keyword
Use volatile for visibility guarantees between threads and understand its limitations compared to synchronization.
Null Safety: Optional Best Practices
Use Optional correctly as a return type and avoid the anti-patterns that make code worse.
Java Collections Framework Overview
Navigate the JCF hierarchy: know which interface to use, which implementation to pick, and the time complexities.
The final Keyword: Variables, Methods & Classes
Understand the three uses of final and their implications for immutability, inheritance, and performance.
Java Concurrency Utilities: CountDownLatch, CyclicBarrier, Semaphore
Coordinate thread execution with synchronization aids beyond wait/notify.
Diamond Problem & Default Methods in Interfaces
Understand how Java resolves conflicts when a class inherits the same default method from multiple interfaces.