OOPS IN JAVA – 50 DESCRIPTIVE INTERVIEW QUESTIONS AND ANSWERS
1. What is OOPS in Java? OOPS in Java is a programming paradigm that organizes software
design around objects rather than functions. It helps in building modular, reusable, secure, and
maintainable applications.
2. What is a class in Java? A class is a blueprint or template used to create objects. It defines
variables and methods and does not occupy memory until an object is created.
3. What is an object in Java? An object is an instance of a class that represents a real-world entity
and occupies memory.
4. What are the main features of OOPS? Encapsulation, inheritance, polymorphism, and
abstraction.
5. Explain encapsulation. Encapsulation binds data and methods together and restricts direct
access using access modifiers.
6. Why is encapsulation important? It protects data, improves maintainability, and ensures
controlled access.
7. What is data hiding? Restricting direct access to class data for security purposes.
8. What is inheritance? Inheritance allows one class to acquire properties and methods of another
class.
9. Advantages of inheritance? Code reusability, reduced duplication, and easier maintenance.
10. Types of inheritance in Java? Single, multilevel, and hierarchical inheritance.
11. What is polymorphism? Ability of a method to take multiple forms.
12. Compile-time polymorphism? Achieved using method overloading.
13. Runtime polymorphism? Achieved using method overriding.
14. What is abstraction? Hiding implementation details and showing essential features.
15. Abstract class? A class that cannot be instantiated and may contain abstract methods.
16. Interface? A fully abstract structure supporting multiple inheritance.
17. Abstract class vs Interface? Abstract class supports partial abstraction; interface supports full
abstraction.
18. Access modifiers? Public, private, protected, default.
19. Constructor? Special method to initialize objects.
20. Garbage collection? Automatic memory management to remove unused objects.
21. Tight coupling? Strong dependency between classes.
22. Loose coupling? Minimal dependency using abstraction.
23. Cohesion? Degree of relatedness of class responsibilities.
24. Coupling? Degree of dependency between classes.
25. Design pattern? Reusable solution to common design problems.
26. Singleton pattern? Ensures one instance of a class.
27. Factory pattern? Creates objects without exposing creation logic.
28. == vs equals()? == compares references, equals() compares content.
29. Why String immutable? For security and performance.
30. final keyword? Restricts modification.
31. Static method overriding? Not possible.
32. Private method inheritance? Not possible.
33. Upcasting? Child object referred by parent reference.
34. Downcasting? Parent reference converted to child reference.
35. Runtime binding? Method resolution at runtime.
36. Private constructor? Used in Singleton pattern.
37. Multiple inheritance issue? Avoids ambiguity and diamond problem.
38. Object lifecycle? Creation, usage, GC, destruction.
39. Stack vs Heap? Stack stores method calls, heap stores objects.
40. Role of OOPS? Improves scalability, reuse, and maintainability.