🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← All topics

Quiz: SOLID Principles: questions with answers

10 questions, each with the answer and a short explanation.

Take the timed quiz + get a certificate →
  1. Q1. Which principle says "a class should have only one reason to change"?
  2. Q2. Adding a new payment type by writing a new class, without editing existing code, follows:
  3. Q3. A Square subclass that breaks code written for Rectangle violates:
  4. Q4. Passing a database object into a service's constructor instead of creating it inside is an example of:
  5. Q5. A fat interface forcing classes to implement methods they don't need violates:
  6. Q6. What is the difference between Dependency Inversion and Dependency Injection?
  7. Q7. What does this print? (code)
  8. Q8. A subclass overrides an inherited method only to throw "operation not supported". Which principle is likely violated?
  9. Q9. Why does OrderService that creates new MySQLDatabase() inside itself make testing hard?
  10. Q10. A basic printer class is forced to implement scan() and fax() with errors. What is the fix?