Home › Blog › OOP interview questions: the four pillars and beyond

OOP interview questions: the four pillars and beyond

OOP interviews start with the four pillars — encapsulation, abstraction, inheritance and polymorphism — and then test whether you can apply them: when to use an interface or an abstract class, why composition is often better than inheritance, how overloading differs from overriding, and what the SOLID principles mean in real code. Give a one-sentence definition, a short example in your language, and a reason it matters. That pattern answers almost every OOP question well.

Fifteen common OOP interview questions

  1. What are the four pillars of OOP?
  2. What is the difference between a class and an object?
  3. Encapsulation versus abstraction?
  4. What types of inheritance exist, and what is the diamond problem?
  5. Compile-time versus runtime polymorphism?
  6. Method overloading versus overriding?
  7. Interface versus abstract class?
  8. Why prefer composition over inheritance?
  9. What are constructors and destructors? What is constructor chaining?
  10. What do access modifiers do?
  11. What is the difference between static and instance members?
  12. What are the SOLID principles?
  13. What is coupling and cohesion?
  14. What is a shallow versus deep copy?
  15. Design classes for a simple library system.

The four pillars, briefly

Distinctions interviewers love

PairKey difference
Overloading vs overridingSame name, different parameters, resolved at compile time vs subclass redefines a parent method, resolved at runtime
Interface vs abstract classPure contract (a class can implement many) vs partial implementation with shared state (usually single inheritance)
Composition vs inheritanceHas-a, flexible and swappable vs is-a, tight coupling to the parent
Static vs instanceBelongs to the class vs belongs to each object
Shallow vs deep copyCopies references vs copies the referenced objects too

SOLID in plain terms

Common traps

The diamond problem and language differences

If class D inherits from B and C, which both inherit from A and override the same method, which version does D get? C++ allows multiple inheritance and resolves it with virtual inheritance; Java and C# avoid it by allowing only single class inheritance but multiple interfaces (with default-method conflicts resolved explicitly); Python uses a method resolution order. Mentioning how your own language handles it shows real understanding. Language-specific detail is in our Java, C++ and Python guides.

Applying OOP in a design question

For “design a library system”, identify nouns (Book, Member, Loan, Librarian), give each a clear responsibility, use composition (a Library has Books), use an interface where behaviour varies (a FinePolicy), and keep state changes behind methods (Loan.return() computes fines). That small exercise is often the bridge to a full object-oriented design interview.

Practising

The fastest way to find gaps is to be asked. Run a spoken mock round on OOP topics — a free AI interview assistant such as CoPilot Interview builds one from your résumé and the job description and scores every answer — then study whatever you stumbled on. Prepare a ten-line code example for each pillar in your main language — writing it once fixes the definitions in memory.

Disclosure: CoPilot Interview is our product, so weigh what we say about it accordingly. Everything else on this page applies whichever tool you use, or none.

Frequently asked questions

What are the four pillars of OOP?

Encapsulation, abstraction, inheritance and polymorphism: bundling data with behaviour, hiding implementation details, reusing and extending classes, and using one interface with many implementations.

What is the difference between an interface and an abstract class?

An interface defines a contract a class can implement alongside others; an abstract class can include shared state and partial implementation but is usually limited to single inheritance.

Why is composition preferred over inheritance?

Composition builds behaviour from swappable parts and avoids the tight coupling and fragile hierarchies that deep inheritance creates.

What is runtime polymorphism?

When a call to an overridden method is resolved at runtime based on the actual object type, so a Shape reference calls the Circle or Square version as appropriate.

Practise on real interview questions

Run 145 real interview questions across 10 tracks, answer out loud and see a structured answer to compare with yours. Free, no signup.

Try a practice question