Interview Question

What are the four pillars of OOP?

The four common OOP ideas are encapsulation, abstraction, inheritance, and polymorphism.

💡 Concept ✅ Quick Revision ☕ Java

Answer

The commonly taught OOP pillars are encapsulation, abstraction, inheritance, and polymorphism. • Encapsulation controls access to state and behavior. • Abstraction exposes useful contracts while hiding details. • Inheritance and polymorphism support substitution and specialized behavior.

Example

Code
interface Shape { double area(); }
final class Square implements Shape {
    private final double side;
    Square(double side) { this.side = side; }
    public double area() { return side * side; }
}

Quick Revision

The four common OOP ideas are encapsulation, abstraction, inheritance, and polymorphism.