OOP

SOLID Interview Questions

What are the SOLID principles? Give a one-line example of each — 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 Intermediate
Question

What are the SOLID principles? Give a one-line example of each.

Answer:

S, single responsibility: InvoiceParser parses invoices. It does not also send email. O, open/closed: I add a new Payment type by a new class, not by editing a switch every time. L, Liskov: a Square that breaks Rectangle setters is not a safe subclass. I, interface segregation: I do not force a robot to implement Eat() because a fat Worker interface had it. D, dependency inversion: I inject IEmailSender. I do not new SmtpClient inside the order service. In a real interview I pick one I actually used — usually SRP or DIP — and describe a PR where I split a god class or injected an interface for tests.

Question 2
Interview Intermediate
Question

Give a one-line smell for each SOLID violation.

Answer:

S: Manager that sends email and writes SQL. O: a switch I must edit for every new type. L: subclass that throws on a parent method. I: fat interface with empty methods. D: new SqlServerRepo() inside a domain service. Then I name the refactor for each.

Question 3
Interview Advanced
Question

Which SOLID principle do you break first under a deadline?

Answer:

I often shove a branch into an existing class — OCP and SRP take the hit. I leave a test and extract a strategy next. I try not to break LSP. DIP I protect on payment boundaries. I would not pretend I never break SOLID.

Question 4
Interview Beginner
Question

How does Strategy relate to OCP?

Answer:

New behavior is a new class on an interface. The context does not change. A switch with a new case is the violation. I wire strategies with DI. SOLID without patterns is abstract; Strategy is the example I keep ready.

Question 5
Interview Intermediate
Question

Why not one IRepository with twenty methods?

Answer:

Callers that only need GetById still depend on DeleteAll. I would split read and write interfaces. I would not split so far that I have IHasId. ISP is about client need.

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