← Back to Home

Java Interview Questions — What Senior Engineers Need to Know

By Nikola Pashov

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.

All 60 Questions

JVM vs JRE vs JDKEntry
What are the differences between JVM, JRE, and JDK?

The JVM, JRE, and JDK are nested components of the Java platform, each building on the previous.

Read full answer →
Java Platform IndependenceEntry
Why is Java a platform-independent language?

Java's platform independence is summarized by the principle "Write Once, Run Anywhere" (WORA).

Read full answer →
How JVM WorksMid
How does the JVM work?

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 →
Main Features of JavaEntry
What are the main features of Java?

Java is defined by a set of deliberate design choices that have kept it relevant for three decades.

Read full answer →
public static void mainEntry
What is the significance of 'public static void main(String[] args)' in Java?

The `public static void main(String[] args)` signature is Java's program entry point — the method the JVM calls to start execution.

Read full answer →
String Constant PoolMid
What is the String Constant Pool in Java?

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.

Read full answer →
String ImmutabilityMid
Why are Strings immutable in Java?

String immutability in Java means that once a `String` object is created, its character sequence cannot be changed.

Read full answer →
StringBuffer vs StringBuilderEntry
What is the difference between StringBuffer and StringBuilder?

Both `StringBuffer` and `StringBuilder` are mutable character sequences used when you need to build or modify strings without creating multiple intermediate `String` objects.

Read full answer →
hashCode() and equals()Mid
What is the importance of hashCode() and equals() methods in Java?

The `equals()` method defines logical equality between objects — whether two instances should be considered the same value.

Read full answer →
Checked vs Unchecked ExceptionsEntry
What is the difference between checked and unchecked exceptions in Java?

In Java, exceptions are divided into checked and unchecked.

Read full answer →
Wrapper ClassesEntry
What are wrapper classes in Java?

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.

Read full answer →
Why Java is Not Pure OOPEntry
Why is Java not considered a pure object-oriented programming language?

A pure object-oriented language treats everything as an object and only allows object-based operations.

Read full answer →
Abstract Class vs InterfaceMid
What is the difference between an abstract class and an interface in Java?

Abstract classes and interfaces both enable abstraction, but they serve different design purposes.

Read full answer →
Marker InterfacesMid
What are marker interfaces in Java?

A marker interface is an interface that declares no methods or fields.

Read full answer →
Java Collections FrameworkEntry
What are collections in Java?

The Java Collections Framework (JCF) is a unified architecture for representing and manipulating groups of objects.

Read full answer →
ArrayList vs VectorEntry
What are the differences between ArrayList and Vector?

Both `ArrayList` and `Vector` are `List` implementations backed by a resizable array, and they share the same core operations.

Read full answer →
finalize() MethodMid
What is the finalize() method in Java?

`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.

Read full answer →
Comparable vs ComparatorMid
What is the difference between the Comparable and Comparator interfaces?

`Comparable` and `Comparator` are both interfaces used for ordering objects, but they serve different design purposes.

Read full answer →
Inner ClassesMid
What is an inner class in Java?

An inner class is a class defined within the body of another class or interface.

Read full answer →
final vs finally vs finalize()Entry
What is the difference between final, finally, and finalize() in Java?

These three keywords sound similar but serve completely different purposes.

Read full answer →
== vs equals()Entry
What is the difference between '==' and the equals() method in Java?

In Java, `==` and `equals()` test different things and the distinction is fundamental to writing correct code.

Read full answer →
Method Overloading vs OverridingEntry
What is method overloading and method overriding in Java?

Method overloading and method overriding are both forms of polymorphism but operate at different phases and on different axes.

Read full answer →
HashMap vs HashtableMid
What is the difference between HashMap and Hashtable?

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 vs LinkedListMid
What is the difference between ArrayList and LinkedList?

ArrayList and LinkedList are both implementations of the List interface in Java, but they are backed by fundamentally different data structures.

Read full answer →
Java Reflection APISenior
What is the Java Reflection API?

The Java Reflection API, in the `java.lang.reflect` package, enables a program to examine and modify its own structure and behavior at runtime.

Read full answer →
JVM Memory AreasSenior
What are the different memory areas allocated by the JVM?

The JVM divides memory into several runtime data areas, each with a specific purpose and lifecycle.

Read full answer →
throw vs throwsEntry
What is the difference between throw and throws in Java?

`throw` and `throws` are both part of Java's exception mechanism but operate at different points and serve different purposes.

Read full answer →
Singleton Pattern in JavaMid
What is a Singleton class and how do you create one in Java?

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.

Read full answer →
Java 8 Stream APIMid
What are the main features of the Java 8 Stream API?

The Stream API, introduced in Java 8 in `java.util.stream`, enables functional-style processing of sequences of elements through declarative, composable pipelines.

Read full answer →
Fail-fast vs Fail-safe IteratorsMid
What is the difference between fail-fast and fail-safe iterators?

The terms fail-fast and fail-safe describe how iterators behave when the underlying collection is modified during iteration.

Read full answer →
Process vs Thread in JavaMid
What is the difference between a process and a thread in Java?

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 →
Creating Threads in JavaEntry
What are the different ways to create a thread in Java?

Java provides several mechanisms to create and run threads, each with different tradeoffs.

Read full answer →
Synchronization in JavaMid
What is synchronization in Java?

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 →
Deadlock in JavaSenior
What is deadlock in Java and how can it be avoided?

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.

Read full answer →
volatile KeywordSenior
What is the volatile keyword in Java?

The volatile keyword in Java is a field modifier that guarantees visibility and ordering guarantees for a variable across multiple threads.

Read full answer →
transient KeywordMid
What is the transient keyword in Java?

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.

Read full answer →
Serialization and DeserializationMid
What is serialization and deserialization in Java?

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.

Read full answer →
Functional InterfacesMid
What are functional interfaces in Java?

A functional interface in Java is an interface that declares exactly one abstract method.

Read full answer →
Lambda ExpressionsMid
What are lambda expressions in Java?

Lambda expressions, introduced in Java 8, are anonymous function literals that implement a functional interface inline without the boilerplate of an anonymous inner class.

Read full answer →
Collection vs CollectionsEntry
What is the difference between Collection and Collections in Java?

Collection (singular, no 's') is the root interface in the Java Collections Framework hierarchy.

Read full answer →
Set vs ListEntry
What is the difference between Set and List in Java?

List and Set are both sub-interfaces of Collection but with fundamentally different contracts around ordering and uniqueness.

Read full answer →
HashSet vs TreeSetMid
What is the difference between HashSet and TreeSet?

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 →
Diamond Problem in JavaSenior
What is the diamond problem in Java?

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.

Read full answer →
Dependency Injection in JavaMid
What is dependency injection in Java?

Dependency injection (DI) is a design pattern implementing the Inversion of Control (IoC) principle.

Read full answer →
Shallow Copy vs Deep Copy in JavaMid
What is the difference between shallow copy and deep copy in Java?

A shallow copy creates a new object and copies the top-level field values from the original.

Read full answer →
Design Patterns in JavaMid
What are design patterns in Java?

Design patterns are proven, reusable solutions to commonly recurring software design problems.

Read full answer →
Factory Design PatternMid
What is the Factory design pattern?

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.

Read full answer →
Builder Design PatternMid
What is the Builder design pattern?

The Builder pattern separates the construction of a complex object from its representation, allowing the same construction process to produce different configurations.

Read full answer →
Heap vs Stack MemoryMid
What is the difference between Heap and Stack memory in Java?

In Java, memory is divided into two primary regions: the stack and the heap.

Read full answer →
Garbage Collection in JavaMid
What is garbage collection in Java?

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.

Read full answer →
Types of Garbage CollectorsSenior
What are the different types of garbage collectors in Java?

Java provides several garbage collector implementations, each representing a different set of tradeoffs between throughput, latency, and resource usage.

Read full answer →
wait() vs sleep()Mid
What is the difference between wait() and sleep() in Java?

wait() and sleep() both pause thread execution, but they serve entirely different purposes and behave very differently with respect to locks.

Read full answer →
notify() vs notifyAll()Senior
What is the difference between notify() and notifyAll() in Java?

Both notify() and notifyAll() are Object methods that wake threads suspended in wait() on the same object's monitor.

Read full answer →
Immutable Class in JavaMid
What is an immutable class and how do you create one?

An immutable class is a class whose instances cannot be modified after construction.

Read full answer →
String vs StringBuilder vs StringBufferEntry
What is the difference between String, StringBuilder, and StringBuffer?

String, StringBuilder, and StringBuffer all represent character sequences in Java but differ critically in mutability and thread safety.

Read full answer →
Static vs Instance VariablesEntry
What is the difference between static and instance variables in Java?

Static variables (also called class variables) are declared with the static keyword and belong to the class itself rather than any particular object.

Read full answer →
super KeywordEntry
What is the purpose of the super keyword in Java?

The super keyword in Java is a reference to the parent (superclass) of the current class.

Read full answer →
this KeywordEntry
What is the purpose of the this keyword in Java?

The this keyword in Java is an implicit reference to the current object — the instance on which the current method or constructor is executing.

Read full answer →
Java GenericsMid
What are generics in Java?

Java generics, introduced in Java 5, allow classes, interfaces, and methods to be parameterized by type.

Read full answer →
Type Erasure in GenericsSenior
What is type erasure in Java generics?

Type erasure is the mechanism by which the Java compiler removes all generic type parameters from the bytecode it produces.

Read full answer →

How to Prepare

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.

Related Topics

  • CS Fundamentals Interview Questions
  • Frameworks Interview Questions
  • Design Principles Interview Questions
  • Technical Interview Practice

Test Your Knowledge

Take a free AI-graded assessment across multiple domains. No signup required.

Start Free Assessment
GrindQuestionsAITechnical interview assessment
TermsPrivacyAboutCompare Tools