Java Interview Questions for Freshers | Basic Core Java Q&A Guide

Java Interview Questions for Freshers (With Answers)

Java is one of the most popular programming languages used in software development, backend systems, Android apps, and enterprise applications. Freshers are usually asked basic concepts, OOP principles, and core Java fundamentals.

Below are the most commonly asked Java interview questions with simple answers.


1. What is Java?

Answer:
Java is a high-level, object-oriented, platform-independent programming language developed by Sun Microsystems. It follows the principle of “Write Once, Run Anywhere” (WORA).


2. What are the features of Java?

Answer:

  • Simple
  • Object-oriented
  • Platform independent
  • Secure
  • Robust
  • Multithreaded
  • High performance

3. What is JVM?

Answer:
JVM (Java Virtual Machine) is a part of JRE that runs Java bytecode and makes Java platform independent.


4. What is JDK and JRE?

JDKJRE
Java Development KitJava Runtime Environment
Used for developmentUsed for running programs
Contains compilerDoes not contain compiler

5. What is OOP?

Answer:
OOP (Object-Oriented Programming) is a programming style based on objects and classes.


6. What are the 4 pillars of OOP?

Answer:

  • Encapsulation
  • Inheritance
  • Polymorphism
  • Abstraction

7. What is a class?

Answer:
A class is a blueprint for creating objects.


8. What is an object?

Answer:
An object is an instance of a class.


9. What is inheritance?

Answer:
Inheritance allows one class to acquire properties of another class.

Example types:

  • Single
  • Multilevel
  • Hierarchical

10. What is polymorphism?

Answer:
Polymorphism means “many forms”. It allows methods to perform different tasks.

Types:

  • Compile-time (Method Overloading)
  • Run-time (Method Overriding)

11. What is method overloading?

Answer:
Same method name but different parameters.


12. What is method overriding?

Answer:
Child class provides a specific implementation of a method already defined in parent class.


13. What is encapsulation?

Answer:
Encapsulation is wrapping data and methods into a single unit (class) and restricting access using access modifiers.


14. What is abstraction?

Answer:
Abstraction hides implementation details and shows only functionality.

Achieved using:

  • Abstract classes
  • Interfaces

15. What are access modifiers in Java?

Answer:

  • private
  • default
  • protected
  • public

16. What is constructor?

Answer:
A constructor is a special method used to initialize objects.


17. What is difference between constructor and method?

ConstructorMethod
Initializes objectPerforms actions
Same name as classAny name
No return typeHas return type

18. What is array in Java?

Answer:
An array is a collection of elements of the same data type.


19. What is String in Java?

Answer:
String is a sequence of characters and is immutable in Java.


20. What is exception handling?

Answer:
Exception handling is used to handle runtime errors using:

  • try
  • catch
  • finally
  • throw
  • throws

21. What is difference between == and equals()?

Answer:

  • == compares memory reference
  • equals() compares content

22. What is multithreading?

Answer:
Multithreading allows multiple threads to run simultaneously.


23. What is garbage collection?

Answer:
Garbage collection automatically removes unused objects from memory.


24. What is static keyword?

Answer:
Static is used for memory management. It belongs to the class, not objects.


25. What is final keyword?

Answer:
Final is used to restrict:

  • Variable → constant
  • Method → cannot override
  • Class → cannot inherit