ZZomato·BehavioralL3DSA Round

OOPs Principles: Encapsulation, Abstraction, Polymorphism, Inheritance

viaGlassdoor

Q: Explain the four pillars of Object-Oriented Programming with concrete examples. A: Encapsulation - bundling data and the methods that operate on it inside a class, hiding internal state behind private fields and exposing controlled access via public methods (e.g., a BankAccount class exposing deposit()/withdraw() but keeping balance private). Abstraction - exposing only essential behavior while hiding implementation details, typically via abstract classes or interfaces (e.g., a PaymentProcessor interface with pay(), implemented differently by CreditCardProcessor and UPIProcessor). Polymorphism - the ability of different classes to be treated through a common interface, with behavior resolved at runtime (method overriding) or compile-time (method overloading), e.g., a Shape base class with area() overridden by Circle and Rectangle. Inheritance - a class (subclass) acquiring properties/behavior of another (superclass), enabling code reuse, e.g., Car and Bike both inheriting from Vehicle. Interviewers expect you to back each definition with a real or project example, not just the textbook definition.

Add a follow-up question they asked
No follow-ups yet. Be the first to add one.
asked …
LeaderboardSalary
Language
Account