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.

Library 77 topics

beginner

Encapsulation in Java

Hide internal state behind access modifiers and expose behavior through public methods.

OOPDesignBest Practices
beginner

Inheritance & Method Resolution

Understand how Java resolves which method to call when classes form an inheritance hierarchy.

OOPPolymorphismFundamentals
beginner

Polymorphism: Compile-Time & Runtime

Distinguish between static (overloading) and dynamic (overriding) polymorphism and know when each applies.

OOPPolymorphismInterview Classic
beginner

Abstraction in Java

Use abstract classes and interfaces to define contracts without exposing implementation.

OOPDesignFundamentals
beginner

Abstract Classes vs Interfaces

Know exactly when to choose an abstract class over an interface — a top-5 Java interview question.

OOPInterview ClassicDesign
beginner

Method Overloading Rules

Know the exact rules Java uses to resolve overloaded methods and the common pitfalls with autoboxing and varargs.

FundamentalsInterview ClassicLanguage Rules
beginner

Method Overriding & @Override

Understand the rules for valid overrides and why @Override is non-negotiable.

OOPFundamentalsBest Practices
intermediate

Composition over Inheritance

Know why delegation through composition is usually better than extending a class.

DesignBest PracticesInterview Classic
beginner

Object Class Methods

Know every method in java.lang.Object and when to override each one.

FundamentalsInterview ClassicBest Practices
beginner

Access Modifiers

Understand the four access levels in Java and their scope: private, default, protected, public.

FundamentalsLanguage RulesEncapsulation
beginner

The static Keyword

Know every use of static in Java: fields, methods, blocks, nested classes, and imports.

FundamentalsLanguage FeatureInterview Classic
beginner

The final Keyword

Know every use of final: variables, methods, classes, and how it affects immutability and performance.

FundamentalsImmutabilityLanguage Feature
beginner

The this & super Keywords

Know every use of this and super: field access, constructor chaining, method calls, and passing the current instance.

FundamentalsLanguage FeatureConstructor
intermediate

Initialization Blocks: Static & Instance

Understand the order of execution of static blocks, instance blocks, constructors, and field initializers.

FundamentalsInterview ClassicInitialization
beginner

Variable Scoping & Shadowing

Know how Java resolves variable names when local, instance, and class-level variables share the same name.

FundamentalsLanguage RulesDebugging
beginner

Primitive Types & Wrapper Classes

Know all 8 primitives, their sizes, default values, and the corresponding wrapper classes.

FundamentalsInterview ClassicPerformance
beginner

Autoboxing & Unboxing Pitfalls

Know when Java automatically converts between primitives and wrappers, and the performance and correctness traps.

PerformanceInterview ClassicGotchas
beginner

Type Casting: Widening & Narrowing

Know when Java casts automatically (widening), when you must cast explicitly (narrowing), and the data loss risks.

FundamentalsType SystemGotchas
beginner

String Immutability & String Pool

Understand why Strings are immutable, how the String Pool works, and the performance implications.

FundamentalsPerformanceInterview Classic
beginner

StringBuilder vs StringBuffer

Know the difference, when to use each, and why StringBuilder replaced StringBuffer in modern code.

PerformanceFundamentalsString Handling
beginner

equals() & hashCode() Contract

Understand the contract between equals and hashCode, and what breaks when you violate it.

Interview ClassicCollectionsBest Practices
intermediate

Generics Fundamentals

Understand type parameters, type safety at compile time, and why generics exist.

Type SystemFundamentalsCollections
advanced

Type Erasure

Understand how generics are implemented via erasure and the limitations this creates.

GenericsType SystemInterview Classic
intermediate

Bounded Type Parameters & Wildcards

Know the difference between <T extends X>, <? extends X>, <? super X>, and PECS (Producer Extends, Consumer Super).

GenericsPECSInterview Classic
intermediate

Enums & Enum Methods

Use enums as type-safe constants with behavior — fields, methods, abstract methods, and implementing interfaces.

FundamentalsDesign PatternsType Safety
intermediate

Annotations & Custom Annotations

Understand built-in annotations, create custom ones, and know the retention policies.

MetaprogrammingFrameworksLanguage Feature
intermediate

Varargs & Heap Pollution

Understand variable-length arguments, their array backing, and the safety concerns with generic varargs.

Language FeatureGenericsGotchas
beginner

Pass by Value in Java

Java is ALWAYS pass by value — understand what this means for primitives and objects.

Interview ClassicFundamentalsLanguage Rules
intermediate

Inner Classes: Static, Member, Local, Anonymous

Know the four types of inner classes, when each is appropriate, and their relationship to the enclosing instance.

Language FeatureMemoryDesign
intermediate

Lambda Expressions

Write concise function literals and understand how they relate to functional interfaces, closures, and anonymous classes.

Functional ProgrammingJava 8Interview Classic
intermediate

Default & Static Methods in Interfaces

Understand why Java 8 added default methods, how they enable interface evolution, and resolution rules for conflicts.

Java 8Interface DesignAPI Evolution
intermediate

Marker Interfaces

Understand Serializable, Cloneable, and the marker interface pattern — and when annotations replaced it.

Design PatternsSerializationType System
intermediate

Records (Java 14+)

Use records for immutable data carriers with auto-generated equals, hashCode, toString, and accessors.

Modern JavaImmutabilityData Classes
intermediate

Sealed Classes & Interfaces (Java 17)

Restrict which classes can extend a type — enabling exhaustive pattern matching and controlled hierarchies.

Modern JavaType SystemPattern Matching
intermediate

Pattern Matching for instanceof (Java 16)

Eliminate explicit casts after instanceof checks using pattern variables.

Modern JavaPattern MatchingReadability
intermediate

Switch Expressions & Pattern Matching

Use modern switch as an expression with arrow syntax, pattern matching, and guarded patterns.

Modern JavaPattern MatchingExpressions
beginner

Text Blocks (Java 15)

Write multi-line string literals with natural formatting using triple-quote syntax.

Modern JavaString HandlingReadability
beginner

Local Variable Type Inference (var)

Use var for local variables where the type is obvious, and know when NOT to use it.

Modern JavaReadabilityType Inference
advanced

Virtual Threads (Java 21)

Use lightweight virtual threads for high-concurrency I/O workloads without the overhead of platform threads.

Modern JavaConcurrencyProject Loom
advanced

Java Platform Module System (JPMS)

Understand Java modules: module-info.java, exports, requires, and strong encapsulation.

Modern JavaArchitectureEncapsulation
intermediate

Cloning: Shallow vs Deep Copy

Understand Object.clone(), its problems, and the preferred alternatives (copy constructors, factory methods).

FundamentalsImmutabilityInterview Classic
intermediate

Serialization & Deserialization

Understand Java's built-in serialization, serialVersionUID, transient, and the security concerns.

I/OSecurityFundamentals
advanced

Reflection API

Inspect and modify class structure, fields, methods, and constructors at runtime — and know the costs.

MetaprogrammingFrameworksAdvanced
intermediate

Java I/O Streams: Byte vs Character

Distinguish InputStream/OutputStream (bytes) from Reader/Writer (characters) and know when to use each.

I/OFundamentalsFile Handling
advanced

NIO.2 Path & Files API

Use the modern file system API (Path, Files) introduced in Java 7 for file operations.

I/OModern JavaFile Handling
intermediate

The transient Keyword

Exclude fields from Java serialization and understand its interaction with default values.

SerializationSecurityLanguage Feature
beginner

LocalDate, LocalTime & LocalDateTime

Use the modern date/time API (Java 8+) that replaced the broken Date/Calendar classes.

Date/TimeModern JavaFundamentals
intermediate

Regular Expressions in Java

Use Pattern and Matcher for regex operations and know the performance implications of compiled vs inline patterns.

String HandlingPerformanceUtility
intermediate

Iterator, ListIterator & Spliterator

Understand the three iteration interfaces, their capabilities, and when Spliterator enables parallel processing.

CollectionsIterationParallel Processing
intermediate

Fail-Fast vs Fail-Safe Iterators

Understand why ArrayList throws ConcurrentModificationException but ConcurrentHashMap doesn't.

CollectionsConcurrencyInterview Classic
intermediate

TreeMap, TreeSet & Natural Ordering

Use sorted collections backed by Red-Black trees and understand Comparable vs Comparator in this context.

CollectionsSortingData Structures
intermediate

PriorityQueue & Deque

Use priority-based and double-ended queue implementations for scheduling, BFS, and stack/queue patterns.

Data StructuresAlgorithmsCollections
advanced

LinkedHashMap & LRU Cache

Use insertion-order or access-order LinkedHashMap, and build an LRU cache with it.

CollectionsCachingInterview Classic
advanced

Atomic Classes & CAS Operations

Use lock-free thread-safe operations on single variables with AtomicInteger, AtomicReference, and compare-and-swap.

ConcurrencyLock-FreePerformance
advanced

ThreadLocal & InheritableThreadLocal

Store per-thread data without synchronization and understand the memory leak risk.

ConcurrencyWeb DevelopmentMemory
advanced

Fork/Join Framework

Divide computational tasks into subtasks recursively and process them in parallel with work-stealing.

ConcurrencyAlgorithmsPerformance
advanced

BlockingQueue Implementations

Choose the right BlockingQueue for producer-consumer patterns: ArrayBlockingQueue, LinkedBlockingQueue, or SynchronousQueue.

ConcurrencyProducer-ConsumerDesign Patterns
advanced

CopyOnWrite Collections

Use CopyOnWriteArrayList and CopyOnWriteArraySet for read-heavy, write-rare thread-safe scenarios.

ConcurrencyCollectionsDesign Patterns
beginner

try-with-resources & AutoCloseable

Automatically close resources (streams, connections, locks) and avoid resource leaks using the try-with-resources statement.

Resource ManagementBest PracticeError Handling
intermediate

JDBC Basics & PreparedStatement

Connect to databases, execute queries safely with PreparedStatements, and manage transactions.

DatabaseSecurityFundamentals
intermediate

Properties & Configuration Loading

Load configuration from .properties files, system properties, and environment variables in the right order.

ConfigurationBest PracticeDeployment
intermediate

Builder Pattern in Java

Construct complex objects step-by-step with a fluent API, and understand where Lombok's @Builder fits.

Design PatternBest PracticeAPI Design
intermediate

Singleton Pattern & Thread Safety

Implement thread-safe singletons correctly, and know why the double-checked locking idiom requires volatile.

Design PatternConcurrencyInterview Classic
intermediate

Strategy Pattern with Functional Interfaces

Replace class-based strategy implementations with lambdas and functional interfaces for cleaner code.

Design PatternFunctional ProgrammingClean Code
intermediate

Observer Pattern & Event Handling

Implement publish-subscribe in Java using listeners, PropertyChangeSupport, or modern reactive alternatives.

Design PatternEvent-DrivenDecoupling
intermediate

Decorator Pattern & I/O Streams

Understand how Java I/O streams use the Decorator pattern and how to apply it in your own designs.

Design PatternI/OClean Code
advanced

Proxy Pattern & Dynamic Proxies

Use java.lang.reflect.Proxy for runtime interface implementation and understand how frameworks use it.

Design PatternAOPFrameworks
intermediate

Immutability in Java

Design immutable classes correctly and understand their benefits for thread safety and defensive programming.

ImmutabilityThread SafetyBest Practice
intermediate

Factory Method & Abstract Factory

Use factory patterns to decouple object creation from usage, and recognize them in JDK APIs.

Design PatternAPI DesignBest Practice
intermediate

EnumSet & EnumMap

Use specialized, high-performance collections for enum keys/elements instead of HashSet/HashMap.

CollectionsPerformanceEnums
intermediate

Collections.unmodifiable* vs List.of() vs List.copyOf()

Choose the right unmodifiable/immutable collection factory and understand the differences in mutability guarantees.

CollectionsImmutabilityAPI Design
intermediate

Method References & Four Types

Use method references as concise alternatives to lambdas, master all four types, and know when lambdas are clearer.

Functional ProgrammingStreamsClean Code
intermediate

Functional Interfaces & @FunctionalInterface

Understand the core functional interfaces (Predicate, Function, Consumer, Supplier) and create custom ones.

Functional ProgrammingStreamsAPI Design
advanced

Shutdown Hooks & Graceful Termination

Register cleanup logic for JVM shutdown and design applications for graceful termination.

Application LifecycleBest PracticeDeployment
advanced

ServiceLoader & SPI (Service Provider Interface)

Use Java's built-in plugin mechanism to discover and load implementations at runtime.

Plugin ArchitectureDecouplingAdvanced
advanced

Covariant Return Types & Bridge Methods

Understand method overriding with narrower return types and the invisible bridge methods the compiler generates.

Language FeatureOOPAdvanced
beginner

Java Collections Framework Overview

Navigate the JCF hierarchy: know which interface to use, which implementation to pick, and the time complexities.

CollectionsData StructuresFundamentals