OOP Interview Questions and Answers (Object-Oriented Programming)

The OOP concepts every technical interview covers, explained simply.

  1. Q1. Which OOP principle hides internal details and exposes only what's needed?

    • A. Recursion
    • B. Polymorphism
    • C. Inheritance
    • D. Encapsulation
    Show answer

    Answer: D. Encapsulation
    Encapsulation bundles data with methods and restricts direct access.

  2. Q2. When a child class provides its own version of a parent's method, it is called:

    • A. Encapsulation
    • B. Method overriding
    • C. Abstraction
    • D. Method overloading
    Show answer

    Answer: B. Method overriding
    Overriding replaces inherited behaviour; overloading is same name, different parameters.

  3. Q3. Polymorphism means:

    • A. Copying objects
    • B. The same interface behaves differently for different types
    • C. A class having many attributes
    • D. Using many modules
    Show answer

    Answer: B. The same interface behaves differently for different types
    e.g. shape.area() works for Circle and Square, each with its own formula.

  4. Q4. An abstract class:

    • A. Is the same as an interface in every language
    • B. Cannot be inherited
    • C. Cannot be instantiated directly and may have abstract methods
    • D. Has no methods
    Show answer

    Answer: C. Cannot be instantiated directly and may have abstract methods
    Subclasses must implement its abstract methods before objects can be created.

  5. Q5. Inheritance lets a class:

    • A. Avoid constructors
    • B. Hide its data
    • C. Reuse and extend the behaviour of another class
    • D. Run faster
    Show answer

    Answer: C. Reuse and extend the behaviour of another class
    class Dog(Animal) gets Animal's attributes and methods.

  6. Q6. A constructor is:

    • A. A static variable
    • B. A special method called when an object is created
    • C. A loop inside a class
    • D. A method that deletes objects
    Show answer

    Answer: B. A special method called when an object is created
    In Python it's __init__; in Java/C++ it has the class's name.

  7. Q7. What is an object?

    • A. An instance of a class
    • B. A function inside a module
    • C. A blueprint for a class
    • D. A type of loop
    Show answer

    Answer: A. An instance of a class
    The class is the blueprint; objects are built from it.

  8. Q8. 'Composition over inheritance' suggests:

    • A. Always inheriting from one base class
    • B. Using only static methods
    • C. Never using classes
    • D. Building classes by combining objects rather than deep class hierarchies
    Show answer

    Answer: D. Building classes by combining objects rather than deep class hierarchies
    A Car has an Engine, rather than Car being a kind of Engine.

  9. Q9. In Python, a name starting with a double underscore (e.g. __balance) triggers:

    • A. A compile error
    • B. Automatic encryption
    • C. A global variable
    • D. Name mangling, to discourage access from outside
    Show answer

    Answer: D. Name mangling, to discourage access from outside
    It becomes _ClassName__balance, a convention for 'private'.

  10. Q10. Which is an example of method overloading (in languages like Java)?

    • A. A class with two constructors in different files
    • B. add(int, int) and add(double, double) in the same class
    • C. A child class redefining speak()
    • D. Calling super()
    Show answer

    Answer: B. add(int, int) and add(double, double) in the same class
    Same method name, different parameter lists, in the same class.

  11. Q11. What does super() do in Python?

    • A. Makes a method static
    • B. Stops inheritance
    • C. Calls a method from the parent class
    • D. Creates a superclass
    Show answer

    Answer: C. Calls a method from the parent class
    Commonly super().__init__(...) inside a child's constructor.

  12. Q12. A class method in Python receives which first argument?

    • A. super
    • B. cls (the class)
    • C. self (the object)
    • D. Nothing
    Show answer

    Answer: B. cls (the class)
    @classmethod methods get the class; instance methods get self; @staticmethod gets neither.

  13. Q13. Which SOLID principle says a class should have only one reason to change?

    • A. Open/Closed Principle
    • B. Single Responsibility Principle
    • C. Liskov Substitution Principle
    • D. Dependency Inversion Principle
    Show answer

    Answer: B. Single Responsibility Principle
    Each class should do one job well.

  14. Q14. The Open/Closed Principle says software entities should be:

    • A. Open source and closed source
    • B. Easy to open and close
    • C. Public and private
    • D. Open for extension, closed for modification
    Show answer

    Answer: D. Open for extension, closed for modification
    Add new behaviour by extending, not by editing tested code.

  15. Q15. What is the diamond problem?

    • A. An infinite loop in constructors
    • B. Ambiguity when a class inherits from two classes that share a common parent
    • C. A memory leak
    • D. A sorting bug
    Show answer

    Answer: B. Ambiguity when a class inherits from two classes that share a common parent
    Python resolves it with the Method Resolution Order (MRO).

  16. Q16. Which method controls what print(obj) shows in Python?

    • A. __str__
    • B. __call__
    • C. __init__
    • D. __len__
    Show answer

    Answer: A. __str__
    __repr__ is the fallback and is meant for developers.

  17. Q17. An interface (as in Java) mainly defines:

    • A. Method signatures a class promises to implement
    • B. Database tables
    • C. Private variables
    • D. The main() method
    Show answer

    Answer: A. Method signatures a class promises to implement
    It's a contract without (most) implementation.

  18. Q18. Which design pattern ensures a class has only one instance?

    • A. Observer
    • B. Factory
    • C. Adapter
    • D. Singleton
    Show answer

    Answer: D. Singleton
    Used for things like a single configuration or logger object.

  19. Q19. The Observer pattern is used when:

    • A. Many objects need to be notified when one object changes
    • B. Only one object may exist
    • C. Objects must be created in steps
    • D. Two interfaces are incompatible
    Show answer

    Answer: A. Many objects need to be notified when one object changes
    Like subscribing to notifications or event listeners.

  20. Q20. Abstraction in OOP means:

    • A. Copying a class
    • B. Deleting unused classes
    • C. Writing abstract art
    • D. Showing essential features while hiding implementation details
    Show answer

    Answer: D. Showing essential features while hiding implementation details
    A user calls car.start() without knowing how the engine works.

Practised these? Now prove it.

Take a timed mock test with new questions every attempt, earn a verified certificate at 70%+, and get noticed by employers.

Start a mock test