Test your Design Patterns knowledge with a free interactive quiz — 50 questions with answers and explanations. No signup needed to play.
Question 1/5Score 0
What does "GoF" refer to in the design-pattern world?
Questions in this quiz
What does "GoF" refer to in the design-pattern world?
Which best describes the **Strategy** pattern?
Which best describes the **Iterator** pattern?
When should you reach for a design pattern?
Which best describes the **Factory Method** pattern?
Which three categories does the GoF catalog organize patterns into?
Why use design patterns at all?
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?
```
interface Compressor { byte[] compress(byte[] data); }
class GzipCompressor implements Compressor { ... }
class ZstdCompressor implements Compressor { ... }
class Backup {
Backup(Compressor c) { this.c = c; }
void run(byte[] data) { storage.write(c.compress(data)); }
}
``` Which pattern is this?
```
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?
```
Notifier n = new SlackNotifier();
n = new RetryDecorator(n);
n = new LoggingDecorator(n);
n.send("hello"); // logs, retries, then slacks
``` Which pattern is shown?