Top Java Basic Interview Questions and Answers


A complete list of commonly asked Java basic interview questions with simple and clear answers. Useful for freshers, job seekers, and anyone revising Java fundamentals.

1. What is Java?

Java is a high-level, object-oriented, platform-independent programming language.


2. What are the main features of Java?

Platform independent, object-oriented, secure, robust, multithreaded, portable.


3. What is JDK, JRE, and JVM?

  1. JDK: Development kit (compiler + tools)
  2. JRE: Runtime environment (JVM + libraries)
  3. JVM: Executes Java bytecode


4. What is a Class?

A blueprint or template used to create objects.


5. What is an Object?

An instance of a class with state and behavior.


6. What is OOP?

Object-Oriented Programming: Encapsulation, Inheritance, Polymorphism, Abstraction.


7. What is Encapsulation?

Binding data and methods together using classes and access modifiers.


8. What is Inheritance?

Acquiring properties of one class into another using extends.


9. What is Polymorphism?

One method behaving differently in different situations.

Types: Overloading & Overriding.


10. What is Abstraction?

Hiding implementation details using abstract classes or interfaces.


11. What is Method Overloading?

Same method name with different parameters.


12. What is Method Overriding?

Child class redefining parent class method.


13. What are Access Modifiers?

public, private, protected, default — control visibility.


14. What is the difference between == and equals()?

  1. == → compares references
  2. equals() → compares values


15. What is a Constructor?

A special method used to initialize objects.


16. Types of Constructors

Default constructor and Parameterized constructor.


17. What is an Interface?

A collection of abstract methods used to achieve multiple inheritance.


18. What is an Abstract Class?

A class that may contain abstract and non-abstract methods.


19. What is a Package?

A group of related classes (e.g., java.util).


20. What is Exception Handling?

Mechanism to handle runtime errors using try, catch, finally.


21. What are Checked and Unchecked Exceptions?

  1. Checked → Checked at compile time
  2. Unchecked → Occur at runtime


22. What is the final keyword?

Used to restrict class, method, or variable.


23. What is Garbage Collection?

Automatic memory cleanup of unused objects.


24. What is a String?

An immutable sequence of characters stored in the String pool.


25. String vs StringBuilder vs StringBuffer

TypeMutable?Thread-safe?

StringNoNo
StringBuilderYesNo
StringBufferYesYes


26. What are Wrapper Classes?

Classes that convert primitive data types into objects.


27. What is Autoboxing and Unboxing?

  1. Autoboxing: primitive → wrapper
  2. Unboxing: wrapper → primitive


28. What is Multithreading?

Running multiple threads concurrently.


29. What is the volatile keyword?

Ensures that the latest value of a variable is visible to all threads.


30. What is the static keyword?

Belongs to the class, not to objects. Accessible without creating an instance.