Skip to content
Preptima
easyConceptEntryMidSenior

What are the four pillars of OOP, and what is the difference between abstraction and encapsulation?

5 min readUpdated 2026-08-15

Answer

Short answer

Encapsulation, inheritance, polymorphism and abstraction are worth stating as consequences rather than definitions - what each one buys you and what it costs. Abstraction decides what a type means to its caller; encapsulation protects how that meaning is upheld.

Keep oop explicit in the answer because that is the concept the interviewer is actually trying to test. A good oop explanation names the trade-off, the failure mode, and the evidence you would use before choosing. Use oop once more at the decision point so the answer reads as judgement rather than a detached example.

Was this answer helpful?

Likely follow-ups

  • Show me a class with public getters and setters for every field and tell me whether it is encapsulated.
  • When is inheritance the right choice over composition?
  • What does the Liskov substitution principle rule out that the compiler allows?
  • Where does polymorphism make code harder to read rather than easier?

Related questions