Top 3 Solid Interview Questions
Browse 3 real-world technical and behavioral interview questions about Solid. Review scenarios, edge cases, and architectural best practices.
What is the dependency inversion principle, and what exactly is being inverted?
High-level policy should not depend on low-level detail; both should depend on an abstraction. What inverts is ownership of the interface - it belongs to the module that consumes it, not to the one that implements it, which is what reverses the direction of the source dependency.
Give me a real single-responsibility violation you have seen, and how would you refactor it?
A class violates SRP when it has more than one reason to change, not when it has more than one method; the refactor is to split along the axes that have independently churned, such as pricing rules, persistence, and presentation, and to stop splitting once each piece has its own requester.
This interface has twelve methods and every implementation throws UnsupportedOperationException for four of them. What went wrong, and how would you fix it?
The interface was assembled from the union of what implementations do rather than from what any one caller needs, so no implementation can honour the whole contract. Split it by client into role interfaces, working from the call sites rather than from the classes.