Java Interview Questions and Answers

fresher Interview Questions & Answers

Q1. What is Java?

Ans: Java is a high-level, object-oriented programming language developed by Sun Microsystems.

Q2. What are features of Java?

Ans: Platform independent, secure, robust, object-oriented, and multithreaded.

Q3. What is the JVM?

Ans: Java Virtual Machine executes Java bytecode and enables platform independence.

Q4. What is the JDK?

Ans: Java Development Kit includes tools to develop and run Java programs.

Q5. What is a class?

Ans: A class is a blueprint for creating objects.

Q6. What is an object?

Ans: An object is an instance of a class containing states and behaviors.

Q7. What is inheritance?

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

Q8. What is polymorphism?

Ans: Polymorphism allows methods to behave differently based on object context.

Q9. What is encapsulation?

Ans: Encapsulation binds data and methods, hiding implementation details.

Q10. What is abstraction?

Ans: Abstraction hides complex implementation and shows only essential details.

Q11. What is a constructor?

Ans: A special method to initialize objects, called during object creation.

Q12. What is method overloading?

Ans: Same method name with different parameters within the same class.

Q13. What is method overriding?

Ans: Same method redefined in subclass with same signature.

Q14. What are access modifiers?

Ans: Keywords like public, private, protected to set access levels.

Q15. What is static keyword?

Ans: Static members belong to the class rather than instances.