Template Method pattern with a concrete scenario.

Get ready for your Object‑Oriented Programming Test. Use flashcards and multiple-choice questions. Each question includes hints and explanations. Prepare for your exam today!

Multiple Choice

Template Method pattern with a concrete scenario.

Explanation:
The Template Method pattern centers on defining the overall algorithm in a base class as a fixed sequence (the template), while letting subclasses supply the concrete steps. The base class provides the skeleton of the algorithm—a template method that calls several steps in a specific order—and some of those steps are abstract (or have default behavior) so subclasses can customize them. This arrangement lets the common workflow stay consistent across different implementations, while the varying parts are encapsulated in the subclass overrides. That’s why the best description is: the base class defines the algorithm skeleton and subclasses override specific steps. It preserves the overall structure while enabling customization where needed. The idea isn’t to let subclasses dictate the entire sequence, nor to override every behavior, nor to rely on object creation to implement the steps—that would point to different patterns like Strategy, Factory, or Builder, not Template Method.

The Template Method pattern centers on defining the overall algorithm in a base class as a fixed sequence (the template), while letting subclasses supply the concrete steps. The base class provides the skeleton of the algorithm—a template method that calls several steps in a specific order—and some of those steps are abstract (or have default behavior) so subclasses can customize them. This arrangement lets the common workflow stay consistent across different implementations, while the varying parts are encapsulated in the subclass overrides.

That’s why the best description is: the base class defines the algorithm skeleton and subclasses override specific steps. It preserves the overall structure while enabling customization where needed. The idea isn’t to let subclasses dictate the entire sequence, nor to override every behavior, nor to rely on object creation to implement the steps—that would point to different patterns like Strategy, Factory, or Builder, not Template Method.