OOPS interview questions

Master OOPS interview questions with 32+ curated problems, answer outlines, and placement-focused preparation.

Preview Questions

  1. If abstraction hides implementation and encapsulation hides data, can you achieve one without the other?

    Abstraction and encapsulation are closely related but not the same. Abstraction focuses on what a class does, while encapsulation focuses on how it hides data and implementation details. It is possible to have...

  2. Can two unrelated classes be polymorphic without using inheritance or interfaces?

    Yes, two unrelated classes can behave polymorphically even without inheritance or interfaces — this is known as duck typing, and it’s mostly seen in languages like Python or JavaScript. The idea is simple: if two...

  3. Is it possible to achieve encapsulation without using access modifiers (private, protected, etc.)?

    Yes, it is possible to achieve encapsulation even without using access modifiers like private or protected. Encapsulation mainly means keeping data safe from unwanted access and controlling how it’s used — and that can...

  4. What’s the difference between composition and aggregation?

    Composition and aggregation are both types of object relationships in OOP that represent a “has-a” relationship, but they differ in how strongly the objects are connected. In composition, one class completely owns the...

  5. Why is multiple inheritance considered dangerous, and can you achieve it safely in Java without diamond problems?

    Multiple inheritance is considered dangerous because it can create ambiguity and complexity in a program. The main problem is the diamond problem, where a class inherits from two classes that both inherit from the same...

  6. Can a class be both abstract and final? Justify your answer logically.

    No, a class cannot be both abstract and final because the two keywords represent opposite ideas. An abstract class is meant to be inherited — it provides a base structure that subclasses must extend and implement. On...

  7. Static vs Instance Variable: Where Are They Stored in Memory?

    Static and instance variables differ mainly in where and how they are stored in memory. A static variable belongs to the class, not to any specific object. It is stored in the method area (or class area) of memory and...

  8. Difference between OOP and procedural language. Why is OOP used?

    The main difference between Object-Oriented Programming (OOP) and Procedural Programming lies in how they organize and manage code. In procedural programming, the focus is on functions or procedures that operate on...