Skip to main content
PreparationZone Logo
PreparationZone
Back to Fundamentals

Fundamentals · Easy · Free

Explain the four pillars of OOP with a real-world example.

FresherFundamentalsOOP & Language Fundamentals
Model answer

Four pillars of OOP

Object-oriented design bundles data + behavior in objects. The four pillars interviewers expect: encapsulation, inheritance, polymorphism, and abstraction.

  • Encapsulation: Hide fields; expose behavior via methods (bank account balance).
  • Inheritance: Reuse base class behavior (Employee → Manager).
  • Polymorphism: Same interface, different runtime behavior (Payment → UPI/card).
  • Abstraction: Show essentials, hide complexity (NotificationService.send()).
java
interface Payment { void pay(Money amount); }
class UpiPayment implements Payment { public void pay(Money m) { /* UPI API */ } }
Use one domain story (e-commerce checkout) and map all four pillars to it—coherent answers score higher.