Test your SOLID Principles knowledge with a free interactive quiz — 30 questions with answers and explanations. No signup needed to play.
Question 1/12Score 0
What does the "D" in SOLID stand for?
In this round
What does the "D" in SOLID stand for?
A new junior on the team writes a 1500-line `God` class that handles parsing, validation, persistence, and notifications. The single SOLID principle most directly relevant is:
You have a `Report` class with `generatePdf()`, `generateCsv()`, and `generateHtml()`. Adding a new export format requires editing the class. The cleanest fix per SOLID is:
A `PaymentProcessor` class directly instantiates `new StripeClient()` in its constructor. Which principle does this violate?
An `IWorker` interface has methods `work()`, `eat()`, and `sleep()`. A `RobotWorker` implements it but leaves `eat()` and `sleep()` as no-ops. Which principle does this violate?
Which sentence best captures the Liskov Substitution Principle (LSP)?
What does the "I" in SOLID stand for?
A function contains a long `switch` over a `shapeType` field, computing area for each shape. Adding a new shape requires editing the function. Which principle does this most directly violate?
Which pair of principles most often work together when applying the Strategy pattern?
Which sentence best captures the Dependency Inversion Principle (DIP)?
`OrderShipper extends Order` so it can reuse the `total()` method. Per SOLID, this is usually:
A `User` class has 20 methods, half about authentication and half about profile editing. The clearest refactor per SRP is: