ZZomato·Tech KnowledgeL3DSA Round

Four Pillars of OOP

Problem Explain the four pillars of Object-Oriented Programming with concrete examples.

Be ready to discuss

  • Encapsulation: bundling data with the methods that operate on it, hiding internal state behind private fields and exposing controlled access - a BankAccount with public deposit()/withdraw() but a private balance no caller can corrupt.
  • Why encapsulation matters beyond syntax: it lets you enforce invariants in one place and change the internal representation without breaking callers.
  • Abstraction: exposing essential behaviour while hiding implementation, via interfaces or abstract classes - a PaymentProcessor interface with pay(), implemented by CreditCardProcessor and UPIProcessor.
  • Encapsulation vs abstraction: hiding state versus hiding complexity - a distinction worth stating explicitly since they're routinely conflated.
  • Polymorphism: one interface, many implementations, resolved at runtime via method overriding (dynamic dispatch through a vtable) - Shape.area() overridden by Circle and Rectangle.
  • Runtime vs compile-time polymorphism: overriding versus overloading, and why some argue overloading isn't true polymorphism.
  • Inheritance: a subclass acquiring the properties and behaviour of a superclass for code reuse - Car and Bike extending Vehicle.
  • Inheritance's sharp edges: tight coupling, the fragile base class problem, and why "favour composition over inheritance" is the standard advice.
  • The Liskov Substitution Principle as the test for whether an inheritance relationship is legitimate.
  • What's evaluated: backing each pillar with a real example from your own work rather than reciting the textbook definition.
asked …
LeaderboardSalaryAccount