SteelReed

Search

Search posts, questions…

OOP & DesignQuestion 2 / 42

Junior

What are the four pillars of OOP, and does Java support multiple inheritance?

Short answer

The four pillars: encapsulation, abstraction, inheritance, polymorphism. Java lets a class extends only one class but implement many interfaces.

Pillar What it does Java keyword
Encapsulation hides state, exposes only behavior private
Abstraction shows "what", hides "how" interface, abstract
Inheritance reuses and extends a parent class extends, super
Polymorphism one call, behavior depends on the real object override, @Override

3 points to say:

  1. Encapsulation exposes behaviour, not getters and setters.
  2. One parent class, many interfaces.
  3. Polymorphism through interfaces is what Spring uses most.

Keep reading the deep dive

Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.