Java Technical Interview Questions with Answers
1. What are the main features of Java?
Answer: Java is platform-independent, object-oriented, secure, robust, portable, and
supports multithreading.
2. What is the difference between JDK, JRE, and JVM?
Answer: JDK (Java Development Kit) provides tools to develop Java programs, JRE
(Java Runtime Environment) is required to run them, and JVM (Java Virtual Machine)
executes the bytecode.
3. What is the difference between method overloading and overriding?
Answer: Overloading happens within the same class with different parameter lists.
Overriding occurs in subclass with the same method signature as the superclass.
4. What is inheritance in Java?
Answer: Inheritance allows one class to inherit properties and behavior from another
class using the 'extends' keyword.
5. What is the difference between String, StringBuilder, and StringBuffer?
Answer: String is immutable, while StringBuilder and StringBuffer are mutable.
StringBuffer is synchronized, but StringBuilder is not.
6. What is polymorphism?
Answer: Polymorphism allows one interface to be used for different data types. It can
be achieved via method overloading and overriding.
7. What is encapsulation?
Answer: Encapsulation is the process of wrapping data (variables) and methods into
a single unit (class) and restricting access using access modifiers.
8. What is abstraction?
Answer: Abstraction hides implementation details and only shows essential features.
It can be achieved using abstract classes and interfaces.
9. What is the difference between HashMap and Hashtable?
Answer: HashMap is non-synchronized and allows one null key, while Hashtable is
synchronized and doesn’t allow null keys or values.
10. What are Lambda Expressions in Java 8?
Answer: Lambda expressions enable functional programming by allowing you to write
anonymous methods using the syntax `(parameters) -> expression`.