Skip to content
We areTOP 1%

What are the four pillars of object-oriented programming?

EasyConceptOOP & SOLID
Track your progress
First attempt
Re-solve after a few days
Final pass before interviews

Answer

The four pillars are encapsulation, abstraction, inheritance and polymorphism. Together they let you model a problem as objects that hide their internals and can be extended safely.

  • Encapsulation: bundle data with the methods that operate on it and restrict direct access, for example private fields with validated setters.
  • Abstraction: expose what an object does rather than how, through interfaces or abstract classes, such as a PaymentMethod with a pay() method.
  • Inheritance: one class reuses and extends another (a Car is a Vehicle), modelling an is-a relationship.
  • Polymorphism: one interface, many implementations. Compile-time polymorphism is method overloading; run-time polymorphism is method overriding, resolved through dynamic dispatch.

More in OOP & SOLID

Sign in to track your progress

Your checkboxes, streak and activity heatmap are saved to your account and sync across devices. It is free.
Sign in with email

New here? Create an account