OOP

Four Pillars Interview Questions

What are the four pillars of OOP? — spoken sample answer for Indian interviews.

  • 5Questions with answers
  • 3Difficulty levels

Questions (5)

Browse beginner, intermediate, and advanced questions with answers — hide them when you want to self-test.

Question 1
Interview Beginner
Question

What are the four pillars of OOP?

Answer:

The four pillars are encapsulation, abstraction, inheritance, and polymorphism. I would not stop at the names. Encapsulation: I keep balance private on a BankAccount and only change it through deposit and withdraw so I can enforce 'no negative without overdraft'. Abstraction: the caller calls Pay() and does not care whether it is a card or UPI underneath. Inheritance: CreditCardPayment is-a Payment, so I reuse the shared fields. Polymorphism: I have a list of Payment and I call Pay() on each; the runtime picks CardPayment or UpiPayment. Overloading is compile-time, overriding is runtime. If I only list the four words, I have not answered the question.

Question 2
Interview Beginner
Question

Give one production example for each of the four pillars.

Answer:

Encapsulation: private fields, callers never see the HashMap. Abstraction: paymentGateway.charge hides Razorpay versus Stripe. Inheritance: BaseController with auth, OrderController extends it. Polymorphism: List<Shape> and area(), or a Logger interface. I would not reciting definitions. I would tie each to code I have written.

Question 3
Interview Intermediate
Question

Which two pillars do people confuse, and how do you separate them?

Answer:

Encapsulation versus abstraction. Encapsulation hides one object's internals. Abstraction shows a simple interface over a messy system. A private list is encapsulation. A PaymentService interface is abstraction. I have seen candidates use all four words for the same private field.

Question 4
Interview Intermediate
Question

Is inheritance required for polymorphism?

Answer:

No. Interfaces and composition give polymorphism without a deep class tree. List.add works on ArrayList and LinkedList without me subclassing. I would rather implement an interface than extend a concrete class I do not own.

Question 5
Interview Beginner
Question

How would you explain the four pillars to a non-engineer?

Answer:

Encapsulation: you cannot poke the object's guts. Abstraction: a button, not the wires. Inheritance: a new screen reuses login. Polymorphism: the same Save click stores a PDF or a photo. Then I map the academic words. If I cannot explain it without jargon I do not understand it.

Practice with AI mock interviews

Run OOP mock interviews with AI follow-ups, instant feedback, and analytics on AiLx.

Free to start · No credit card required