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.
What are the SOLID principles? Give a one-line example of each.
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.
Give a one-line smell for each SOLID violation.
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.
Which SOLID principle do you break first under a deadline?
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.
How does Strategy relate to OCP?
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.
Why not one IRepository with twenty methods?
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