WorksheetsBehavioral and IOC Design Patterns Quiz
Total questions: 15
Worksheet time: 8mins
Which pattern allows a request to move through multiple handlers until one handles it?
State
Chain of Responsibility
Strategy
Observer
Which pattern focuses on changing an object’s behavior when its internal state changes?
Chain of Responsibility
Command
State
Mediator
In which pattern does the client usually not know which handler processes the request?
State
Chain of Responsibility
Template Method
Strategy
If every handler in a chain processes a request and passes it forward, which pattern is being used?
State
Observer
Chain of Responsibility
Strategy
Which pattern can result in a request being handled by none of the objects?
State
Strategy
Chain of Responsibility
Template Method
Which pattern typically requires each state to know about the next possible state?
Observer
Chain of Responsibility
State
Mediator
Why is Chain of Responsibility preferred over a large if-else block?
Faster execution
Better UI design
Decouples sender from handler
Reduces memory usage
What is a common drawback of Chain of Responsibility?
Too many objects created
Hard to guarantee request handling
Difficult to extend
Tight coupling
State pattern helps mainly to:
Avoid subclassing
Replace conditional logic with polymorphism
Simplify object creation
Control access to objects
Which difference is TRUE?
State decides who handles a request
Chain of Responsibility changes object behavior
State represents behavior based on condition
Chain of Responsibility replaces algorithms
A support ticket moves through L1 → L2 → L3 support until resolved. Which pattern best fits?
State
Chain of Responsibility
Strategy
Observer
An order can be Created, Paid, Cancelled, or Shipped, and each state allows different actions. Which pattern fits best?
Chain of Responsibility
Decorator
State
Factory
A document approval system sends a request to Manager → Director → CEO, but approval may stop at any level. Which pattern is used?
State
Chain of Responsibility
Command
Mediator
A media player behaves differently when in Playing, Paused, or Stopped modes. Which pattern applies?
Strategy
Chain of Responsibility
State
Observer
What's a potential disadvantage of the State pattern?
It makes code less maintainable
Can increase the number of classes significantly
Cannot handle state transitions
Violates Single Responsibility Principle
