Java interviews at the senior level go far beyond syntax. Interviewers expect you to reason about JVM internals, garbage collection trade-offs, the Java Memory Model, and how the collections framework actually works under the hood. Surface-level answers about “HashMap uses hashing” won’t cut it.
These 60 questions cover the concepts that consistently appear in senior Java interviews at top companies: concurrency primitives, class loading, generics and type erasure, functional interfaces, and modern Java features from records to virtual threads. Each question is designed to test whether you can explain why, not just what.
The JVM, JRE, and JDK are nested components of the Java platform, each building on the previous. Understanding their boundaries is essential for knowing what to install in different contexts.
Read full answer →Java's platform independence is summarized by the principle "Write Once, Run Anywhere" (WORA). The mechanism has two steps: compilation to an intermediate representation (bytecode), and execution of that bytecode by a platform-specific JVM.
Read full answer →The JVM processes Java programs through four major subsystems: the class loader, the bytecode verifier, the execution engine, and the runtime memory areas.
Read full answer →Java is defined by a set of deliberate design choices that have kept it relevant for three decades. Understanding these features at depth — not just reciting the list — is what distinguishes strong candidates.
Read full answer →The `public static void main(String[] args)` signature is Java's program entry point — the method the JVM calls to start execution. Every keyword in the signature is load-bearing.
Read full answer →The String Constant Pool (also called String Intern Pool) is a special memory region inside the JVM's heap where string literals are stored and reused. When you write a string literal like `String s = "hello"`, the JVM checks the pool first. If "hello" already exists, it returns the same referenc…
Read full answer →String immutability in Java means that once a `String` object is created, its character sequence cannot be changed. Any operation that appears to modify a string — concatenation, `replace()`, `substring()` — actually creates and returns a new `String` object. The original remains unchanged.
Read full answer →Both `StringBuffer` and `StringBuilder` are mutable character sequences used when you need to build or modify strings without creating multiple intermediate `String` objects. They share the same API — `append()`, `insert()`, `delete()`, `reverse()`, `toString()` — and both inherit from `AbstractS…
Read full answer →The `equals()` method defines logical equality between objects — whether two instances should be considered the same value. The `hashCode()` method returns an integer used by hash-based data structures to bucket objects efficiently. They are defined on `Object` and meant to be overridden together.
Read full answer →In Java, exceptions are divided into checked and unchecked. The distinction determines whether the compiler forces calling code to handle or declare the exception.
Read full answer →Java has eight primitive types — `byte`, `short`, `int`, `long`, `float`, `double`, `char`, and `boolean` — that are not objects and cannot be used where `Object` references are required. Wrapper classes provide an object counterpart for each: `Byte`, `Short`, `Integer`, `Long`, `Float`, `Double`…
Read full answer →A pure object-oriented language treats everything as an object and only allows object-based operations. Java falls short of this standard primarily because of primitive types and static members.
Read full answer →Abstract classes and interfaces both enable abstraction, but they serve different design purposes.
Read full answer →A marker interface is an interface that declares no methods or fields. Its sole purpose is to tag a class as possessing some property, which the JVM, runtime, or framework can then detect via `instanceof` checks. The interface conveys metadata rather than defining a behavioral contract.
Read full answer →The Java Collections Framework (JCF) is a unified architecture for representing and manipulating groups of objects. It consists of interfaces that define abstract data types, concrete implementations of those interfaces, and algorithms (utility methods in `Collections` and `Arrays`) that operate …
Read full answer →Both `ArrayList` and `Vector` are `List` implementations backed by a resizable array, and they share the same core operations. The primary difference is synchronization.
Read full answer →`finalize()` is a method defined on `java.lang.Object` that the garbage collector is permitted to call on an object before reclaiming its memory, giving the object a chance to release native resources or perform cleanup. It was part of Java from version 1.0.
Read full answer →`Comparable` and `Comparator` are both interfaces used for ordering objects, but they serve different design purposes.
Read full answer →An inner class is a class defined within the body of another class or interface. Java has four distinct kinds, each with different scoping and access rules.
Read full answer →These three keywords sound similar but serve completely different purposes.
Read full answer →In Java, `==` and `equals()` test different things and the distinction is fundamental to writing correct code.
Read full answer →Method overloading and method overriding are both forms of polymorphism but operate at different phases and on different axes.
Read full answer →HashMap and Hashtable both implement the Map interface and store key-value pairs using a hash table, but they differ in synchronization, null handling, and historical context.
Read full answer →ArrayList and LinkedList are both implementations of the List interface in Java, but they are backed by fundamentally different data structures.
Read full answer →The Java Reflection API, in the `java.lang.reflect` package, enables a program to examine and modify its own structure and behavior at runtime. It allows code to inspect class metadata, invoke methods, access fields, and instantiate objects using symbolic names rather than compile-time references.
Read full answer →The JVM divides memory into several runtime data areas, each with a specific purpose and lifecycle.
Read full answer →`throw` and `throws` are both part of Java's exception mechanism but operate at different points and serve different purposes.
Read full answer →The Singleton pattern ensures that a class has exactly one instance throughout the application's lifetime and provides a global point of access to it. It is one of the Gang of Four creational patterns.
Read full answer →The Stream API, introduced in Java 8 in `java.util.stream`, enables functional-style processing of sequences of elements through declarative, composable pipelines. A stream is not a data structure — it does not store data. It conveys elements from a source (collection, array, generator function, …
Read full answer →The terms fail-fast and fail-safe describe how iterators behave when the underlying collection is modified during iteration.
Read full answer →A process and a thread are both units of execution, but they operate at different levels of the operating system and have fundamentally different resource isolation models.
Read full answer →Java provides several mechanisms to create and run threads, each with different tradeoffs.
Read full answer →Synchronization in Java is the mechanism by which the JVM controls access to shared resources by multiple threads, preventing data races and ensuring memory visibility.
Read full answer →A deadlock is a situation where two or more threads are permanently blocked, each waiting to acquire a lock held by another thread in the cycle. No thread can proceed, and the application hangs indefinitely without throwing an exception.
Read full answer →The volatile keyword in Java is a field modifier that guarantees visibility and ordering guarantees for a variable across multiple threads. Without volatile, each thread may cache a variable's value in its CPU register or L1/L2 cache, meaning writes by one thread are not necessarily visible to ot…
Read full answer →The transient keyword in Java is a field modifier that instructs the serialization mechanism to skip a field when converting an object to a byte stream. When an object implementing Serializable is serialized, every non-transient field is written to the output. A transient field is omitted entirel…
Read full answer →Serialization is the process of converting a Java object's state into a byte stream so it can be persisted to disk, stored in a database, or transmitted over a network. Deserialization is the inverse: reconstructing an object from that byte stream. Together, they enable objects to outlive the JVM…
Read full answer →A functional interface in Java is an interface that declares exactly one abstract method. This single-abstract-method (SAM) constraint makes the interface usable as the target type for a lambda expression or method reference, enabling functional-style programming introduced in Java 8.
Read full answer →Lambda expressions, introduced in Java 8, are anonymous function literals that implement a functional interface inline without the boilerplate of an anonymous inner class. The syntax is: (parameters) -> expression or (parameters) -> { statements; }. When the parameter type can be inferred from co…
Read full answer →Collection (singular, no 's') is the root interface in the Java Collections Framework hierarchy. It is located in java.util and declares the fundamental contract all collection types must fulfill: add, remove, contains, size, iterator, and similar methods. Interfaces like List, Set, and Queue ext…
Read full answer →List and Set are both sub-interfaces of Collection but with fundamentally different contracts around ordering and uniqueness.
Read full answer →HashSet and TreeSet are both implementations of the Set interface in Java, but they differ fundamentally in their underlying data structures, performance characteristics, and ordering guarantees.
Read full answer →The diamond problem is a classic multiple inheritance ambiguity that arises when a class inherits from two parents that both provide a concrete implementation of the same method, and both parents share a common superclass or interface defining that method. The shape forms a diamond in the inherit…
Read full answer →Dependency injection (DI) is a design pattern implementing the Inversion of Control (IoC) principle. Instead of a class creating its own dependencies with new, those dependencies are provided (injected) from outside — by a framework, factory, or test harness. The class declares what it needs; som…
Read full answer →A shallow copy creates a new object and copies the top-level field values from the original. For primitive fields, this means the value itself is copied. For reference-type fields, only the reference (memory address) is copied — both the original and the copy point to the same nested objects. Mod…
Read full answer →Design patterns are proven, reusable solutions to commonly recurring software design problems. They are not code libraries or algorithms — they are templates describing how to structure classes and objects to solve a specific type of design challenge. The term was popularized by the Gang of Four …
Read full answer →The Factory pattern encapsulates object creation behind a method or class, so callers request objects by type or configuration without depending on concrete class names or constructors. This decouples the consuming code from the instantiation details, making the system easier to extend and test.
Read full answer →The Builder pattern separates the construction of a complex object from its representation, allowing the same construction process to produce different configurations. It is most valuable when an object requires many parameters, some of which are optional, because the alternative — telescoping co…
Read full answer →In Java, memory is divided into two primary regions: the stack and the heap.
Read full answer →Garbage collection (GC) in Java is the automatic process of identifying objects on the heap that are no longer reachable from any GC root (active threads, static fields, local variables on stack) and reclaiming their memory. The developer is freed from manual memory management, eliminating use-af…
Read full answer →Java provides several garbage collector implementations, each representing a different set of tradeoffs between throughput, latency, and resource usage.
Read full answer →wait() and sleep() both pause thread execution, but they serve entirely different purposes and behave very differently with respect to locks.
Read full answer →Both notify() and notifyAll() are Object methods that wake threads suspended in wait() on the same object's monitor. The critical difference is how many threads they wake.
Read full answer →An immutable class is a class whose instances cannot be modified after construction. Once created, an immutable object's state is fixed for its lifetime. java.lang.String, Integer, and the other wrapper types are the canonical examples.
Read full answer →String, StringBuilder, and StringBuffer all represent character sequences in Java but differ critically in mutability and thread safety.
Read full answer →Static variables (also called class variables) are declared with the static keyword and belong to the class itself rather than any particular object. There is exactly one copy of a static variable in memory, shared by all instances of the class. They are initialized when the class is first loaded…
Read full answer →The super keyword in Java is a reference to the parent (superclass) of the current class. It has three primary uses: calling a parent class constructor, calling an overridden parent class method, and accessing a parent class field hidden by a subclass field of the same name.
Read full answer →The this keyword in Java is an implicit reference to the current object — the instance on which the current method or constructor is executing. It has four main uses.
Read full answer →Java generics, introduced in Java 5, allow classes, interfaces, and methods to be parameterized by type. Instead of writing a container that holds Object and requires manual casting, you declare List<String>, and the compiler enforces that only String values are added and returns String values wi…
Read full answer →Type erasure is the mechanism by which the Java compiler removes all generic type parameters from the bytecode it produces. The resulting .class file contains no information about the specific type arguments used — only the erasure (the raw type or the bound) remains. This was a deliberate compat…
Read full answer →Focus on understanding concepts deeply enough to explain them in your own words. For each topic, practice articulating the trade-offs and real-world applications — interviewers care about practical judgment, not textbook definitions.
Take a free AI-graded assessment across multiple domains. No signup required.
Start Free Assessment