Test your Design Patterns knowledge with a free interactive quiz — 50 questions with answers and explanations. No signup needed to play.
Question 1/12Score 0
Which best describes the **Adapter** pattern?
In this round
Which best describes the **Adapter** pattern?
Which best describes the **Strategy** pattern?
Why use design patterns at all?
```
button.addEventListener("click", () => save());
button.addEventListener("click", () => analytics.log("save"));
``` Which design pattern does the browser event system implement?
Which best describes the **Builder** pattern?
```
interface Notification { void send(); }
abstract class Notifier {
abstract Notification create();
void notify() { create().send(); }
}
class EmailNotifier extends Notifier {
Notification create() { return new EmailNotification(); }
}
``` Which pattern is this?
What is an "anti-pattern"?
A drawing app has `Shape.draw()` — `Circle` and `Square` draw themselves, and `Group` (which contains a list of `Shape`s) iterates over its children and calls `draw()` on each. Client code calls `shape.draw()` without caring whether it's a single shape or a group. Which pattern is this?
What is the difference between **Factory Method** and **Abstract Factory**?
```
User u = new User.Builder()
.name("Lena")
.email("lena@example.com")
.age(25)
.build();
``` Which pattern is this?
```
Notifier n = new SlackNotifier();
n = new RetryDecorator(n);
n = new LoggingDecorator(n);
n.send("hello"); // logs, retries, then slacks
``` Which pattern is shown?
Your app expects `Logger.log(msg)` but the new 3rd-party SDK exposes `extLogger.write(level, text)`. You build a `ThirdPartyLoggerAdapter` that exposes `log(msg)` and internally calls `extLogger.write("info", msg)`. Which pattern is this?