Design patterns · interview question
Classify each design pattern.
Matrix / gridMedium
Choose for each row.
| Item | Creational | Structural | Behavioral |
|---|---|---|---|
| Factory Method | |||
| Adapter | |||
| Observer | |||
| Builder | |||
| Decorator | |||
| Strategy |
Answer and explanation
Correct answer
- Factory Method: Creational
- Adapter: Structural
- Observer: Behavioral
- Builder: Creational
- Decorator: Structural
- Strategy: Behavioral
Why
Creational patterns abstract object creation; structural patterns compose classes and objects; behavioral patterns distribute responsibility and communication between objects.
References
- Gamma, Helm, Johnson & Vlissides, Design Patterns: Elements of Reusable Object-Oriented Software (1994)
Test yourself on Design patterns
A free test with instant, explained results. No account needed.
More Design patterns questions
- A code review describes a ConfigManager singleton. Highlight the statements that describe real problems.
- Your checkout flow wants one clean charge(order) call, but each payment provider ships a different SDK. Which design…
- Which principle is most closely aligned with the Factory Pattern?
- Which scenario is least suited for the Decorator pattern?
- Why is it important for a decorator to share the same interface as the object it decorates?
- In an e-commerce application, you want to delay loading product images until they are actually needed. Which design…