Skip to content
codinganthem

SOLID skill check

Practise the SOLID principles: single responsibility, open/closed, Liskov substitution, interface segregation, and dependency inversion, including short code where you name the violation or the fix.

15

Questions

14 min

Timer can't pause

Multiple choice

One answer out of four

Choose a level

Question type

About 40% code reading

Topics

  • Single responsibility
  • Open/closed
  • Liskov substitution
  • Interface segregation
  • Dependency inversion
  • Spotting a violation
  • Refactoring
  • Trade-offs

Do

Use scratch paper or a notepad to work things out. Skip a question and come back to it later.

Don't

Run the code or look up answers during the check. Open the check in more than one tab or window.

Easy · Mixed · 15 questions · 14 min

By starting, you agree to the Terms and Privacy Policy.

Start practice

Practice checks each answer as you go, with an explanation. The exam is checked when you submit; 9 of 15 passes and earns a certificate.

Checking your levels…

Certificates come from the certified exam: pass with 9 of 15 while signed in. View a sample certificate.

Sample SOLID questions with answers

These are never used in a check, so seeing their answers here won't give anything away.

  1. Question 1 · Easy · Single responsibility

    According to the Single Responsibility Principle (SRP), what defines a class's 'responsibility'?
    1. A.A single reason for the class to change
    2. B.The ability to perform only one database transaction at a time
    3. C.Handling only one data type in its properties
    4. D.A single public method exposed to clients
    Show answer

    A. A single reason for the class to change

    Robert C. Martin defines a responsibility in SRP as 'a reason to change', meaning a module or class should be accountable to only one actor or business concern.
  2. Question 2 · Easy · Open/closed

    Which design technique is most commonly used to adhere to the Open/Closed Principle when introducing new payment types into an existing checkout process?
    1. A.Adding new 'case' statements to a switch block inside the core checkout method
    2. B.Creating an interface for payment processing and implementing new payment classes without modifying the checkout class
    3. C.Modifying private helper functions inside the checkout class to support each payment vendor
    4. D.Subclassing the checkout class for every distinct payment method
    Show answer

    B. Creating an interface for payment processing and implementing new payment classes without modifying the checkout class

    The Open/Closed Principle states that software entities should be open for extension but closed for modification. Implementing polymorphic payment strategies via a shared interface allows adding new methods without altering existing checkout logic.
  3. Question 3 · Moderate · Liskov substitution

    Consider the classic Rectangle and Square problem. Why does having a Square subclass override setWidth and setHeight on a base Rectangle to keep sides equal violate the Liskov Substitution Principle (LSP)?
    1. A.Because subclasses are not permitted to override non-abstract methods in object-oriented programming.
    2. B.Because a Square requires more memory than a Rectangle to maintain its invariant.
    3. C.Because clients expecting a Rectangle assume modifying width does not alter height, breaking behavioral invariants.
    4. D.Because Square does not implement an interface distinct from Rectangle.
    Show answer

    C. Because clients expecting a Rectangle assume modifying width does not alter height, breaking behavioral invariants.

    LSP requires that objects of a superclass can be replaced with objects of a subclass without breaking application invariants. Code written for Rectangle assumes rect.setWidth(w) leaves height unchanged, which Square violates.
  4. Question 4 · Advanced · Interface segregation

    A team creates a fine-grained interface for every single public method in their domain services, resulting in hundreds of single-method interfaces. What subtle architecture problem does this misapplication of ISP cause?
    1. A.It fractures cohesive business concepts, forcing clients to assemble and depend on ad-hoc composites without clear cohesion
    2. B.It causes fatal compilation errors in languages that disallow multiple interface inheritance
    3. C.It forces client code into cyclic dependency loops between the interfaces and implementations
    4. D.It violates the Open/Closed Principle because existing interfaces must be renamed whenever an implementation changes
    Show answer

    A. It fractures cohesive business concepts, forcing clients to assemble and depend on ad-hoc composites without clear cohesion

    ISP targets segregating interfaces based on cohesive client needs, not atomizing every method. Deconstructing interfaces to single methods fragments domain cohesion, leading to role explosion and noisy, brittle composition.

How scoring and certificates work

  • Each check has 15 multiple-choice questions with one correct answer, and one timer for the whole check. A question you leave unanswered scores nothing.
  • Practice is free without an account and shows whether each answer is right as you go, with an explanation.
  • The certified exam is scored when you submit. 60% passes, which is 9 of 15. Easy unlocks Moderate, and Moderate unlocks Advanced.
  • Passing the exam while signed in earns a free certificate, valid for one year, with its own verification page. See a sample certificate.