Design Patterns · Junior · Question 18 of 75
Which pattern lets you treat a tree (a menu with submenus, a file system) uniformly?
- ✓Correct answer: Composite
- 2Singleton
- 3Adapter
Explanation
Composite describes both leaves and containers with one interface, so the client traverses the tree without "is it a folder or a file" checks. The React component tree, the DOM and nested menus are natural examples.