Behavioral Patterns «Prev Next»

Common Behavioral Patterns - Quiz

Each question is worth one point. Select the best answer or answers for each question.
1. In Java 21+, which pattern is most directly supported by sealed classes and pattern matching in switch expressions as a modern alternative to classic double-dispatch?
Please select the best answer.
  A. Chain of Responsibility
  B. Visitor
  C. Strategy
  D. Mediator

2. The GoF Observer pattern is foundational to modern reactive programming in Java. Which of the following represents the current Java standard API for reactive publish-subscribe streams, introduced in Java 9?
Please select the best answer.
  A. java.util.Observable
  B. java.util.EventListener
  C. java.util.concurrent.Flow
  D. java.beans.PropertyChangeListener

3. Which of the following patterns allows multiple objects an opportunity to process a request without guaranteeing that any of them must process it?
Please select the best answer.
  A. Chain of Responsibility
  B. Command
  C. Memento
  D. Mediator

4. Which of the following is an object pattern that encapsulates interchangeable algorithms in objects so the algorithm can vary independently of the classes that use it?
Please select the best answer.
  A. Chain of Responsibility
  B. Command
  C. Strategy
  D. Mediator