Top Java Interview Questions (With Short Answers)
1. What are the main features of Java?
Object-oriented
Platform-independent (JVM)
Robust & secure
Multithreaded
Automatic memory management (Garbage Collection)
Rich standard library
2. Explain the OOP principles.
Encapsulation — Wrapping data + methods
Inheritance — Reusing parent properties
Polymorphism — Many forms (overloading/overriding)
Abstraction — Showing essential details only
3. What is JVM, JDK, JRE?
JVM → Runs Java bytecode
JDK → JRE + development tools (compiler, debugger)
JRE → JVM + libraries to run Java applications
4. What is the difference between abstract class and interface?
Abstract Class Interface
Can have abstract + concrete methods Only abstract methods (Java 8+ allows default & static methods)
Can have constructors No constructors
Supports single inheritance Supports multiple inheritance
5. What is method overloading and overriding?
Overloading → Same method name, different parameters (compile-time polymorphism).
Overriding → Child class modifies parent method (runtime polymorphism).
6. What is the difference between == and equals()?
== → Compares memory reference
equals() → Compares object values (can be overridden)
7. What is a constructor?
Special method invoked when an object is created.
Used to initialize object state.
Types: default, parameterized, copy constructor (manually defined).
8. What is the difference between final, finally, and finalize()?
final → Keyword (constant, non-overridable, non-inheritable)
finally → Block always executed in try-catch
finalize() → Method called by GC before object deletion (deprecated)
9. What is the Java Collections Framework?
A set of classes/interfaces for storing data:
List (ArrayList, LinkedList)
Set (HashSet, TreeSet)
Map (HashMap, TreeMap)
Queue, Deque
10. Difference between ArrayList and LinkedList?
ArrayList LinkedList
Dynamic array Doubly-linked list
Fast random access Fast insert/delete
Slow insert/delete Slow random access