Interview Q&A · questions with model answers
Java Developer Interview Questions
Ordered by how often they're asked. Most-asked answers are free to read in full; members see every answer and can rate their confidence on each.
-
Most asked Explain Java concept: == vs equals.
For primitives, == compares values; for objects, == compares references, while equals is intended to compare logical equality.
-
Most asked Explain Java concept: checked vs unchecked exceptions.
Checked exceptions must be declared or handled at compile time; unchecked exceptions are RuntimeException or Error subclasses and do not require declaration.
-
Most asked Explain Java concept: overloading vs overriding.
Overloading chooses between methods with the same name but different parameters at compile time; overriding replaces inherited behavior at runtime through polymorphism.
-
Most asked Explain Java concept: abstract class vs interface.
Use an abstract class when related types share state or base behavior; use an interface to define a capability or contract that many unrelated classes can implement.
-
Most asked Java Collections: ArrayList vs LinkedList?
ArrayList is usually the default list because indexed access is fast and cache-friendly; LinkedList only helps in narrow cases with frequent iterator-based insertions/removals.
-
Most asked JVM memory: heap vs stack?
The heap stores objects shared across method calls, while each thread's stack stores call frames, local variables, and return information.
-
Explain Java concept: JRE vs JDK.
The JRE runs Java applications, while the JDK includes the JRE plus developer tools such as javac, jar, javadoc, jdb, and diagnostic utilities.
-
Explain Java concept: primitive vs reference types.
Primitive variables hold raw values, while reference variables hold references to objects.
-
Java Collections: Comparable vs Comparator?
Comparable defines a type's natural ordering; Comparator defines an external ordering strategy.
-
Concurrency in Java: Callable vs Runnable?
Runnable represents work that returns no result and cannot throw checked exceptions; Callable returns a value and can throw checked exceptions.
-
What is the difference between a servlet Filter and a HandlerInterceptor, and why doesn't @ControllerAdvice handle exceptions thrown in filters?
Filters belong to the servlet container and run around the DispatcherServlet for every request; interceptors run inside Spring MVC for mapped handlers and know which handler will run.…
-
What is the difference between checked and unchecked exceptions in Java?
Checked exceptions must be declared or caught at compile time, while unchecked exceptions inherit from RuntimeException and can occur at runtime without explicit handling.