Design patterns skill check
Test your design patterns: when to use singleton, factory, builder, adapter, decorator, strategy, and observer, and how to recognise them in code.
15
Questions
11 min
Timer can't pause
Multiple choice
One answer out of four
Choose a level
Topics
- Creational patterns
- Singleton
- Factory and builder
- Structural patterns
- Adapter and decorator
- Behavioral patterns
- Strategy and observer
- Choosing a pattern
Do
Use scratch paper or a notepad to work things out. Skip a question and come back to it later.
Don't
Look up answers during the check. Open the check in more than one tab or window.
Easy · 15 questions · 11 min
By starting, you agree to the Terms and Privacy Policy.
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 Design patterns questions with answers
These are never used in a check, so seeing their answers here won't give anything away.
Question 1 · Easy · Singleton
What is the primary purpose of the Singleton pattern?- A.To ensure a class has only one instance and provide a global point of access to it
- B.To decouple an abstraction from its implementation so that both can vary independently
- C.To cache expensive operations and prevent redundant function calls across the application
- D.To allow multiple subclasses to extend a base class without modifying it
Show answer
A. To ensure a class has only one instance and provide a global point of access to it
The Singleton pattern ensures that a class has only one instance while providing a single, global access point to that instance. This is commonly used for managing shared resources like configuration settings or connection pools.Question 2 · Easy · Factory and builder
A class has a constructor with twelve optional parameters, making instantiation error-prone and hard to read. Which creational design pattern directly solves this problem?- A.Abstract Factory
- B.Prototype
- C.Builder
- D.Factory Method
Show answer
C. Builder
The Builder pattern separates the construction of a complex object from its representation, allowing step-by-step configuration of optional parameters and avoiding sprawling constructor overloads (the 'telescoping constructor' anti-pattern).Question 3 · Moderate · Structural patterns
Which pattern provides a simplified, high-level interface to a complex subsystem of interdependent classes without hiding the subsystem classes from advanced callers?- A.Facade
- B.Composite
- C.Flyweight
- D.Proxy
Show answer
A. Facade
Facade defines a higher-level entry point that makes a subsystem easier to use, while still allowing clients to access subsystem classes directly if they require finer-grained control.Question 4 · Advanced · Adapter and decorator
In terms of interface conformance and object identity, how does the Decorator pattern fundamentally differ from the Adapter pattern?- A.A Decorator caches method invocations for optimization, whereas an Adapter always delegates directly.
- B.A Decorator requires multiple wrapped instances, whereas an Adapter can only wrap exactly one instance.
- C.A Decorator conforms strictly to the interface of the wrapped object, whereas an Adapter exposes an entirely different interface.
- D.A Decorator changes the public contract of the wrapped object, whereas an Adapter preserves the original contract unchanged.
Show answer
C. A Decorator conforms strictly to the interface of the wrapped object, whereas an Adapter exposes an entirely different interface.
Decorator conforms to the exact same interface as the wrapped object so it can be used transparently and composed recursively, whereas Adapter specifically translates an existing interface into a different target interface required by the client.
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.