Advanced Object-Oriented Programming Concepts
Q95 / 100

How does the "Open/Closed Principle" relate to the Strategy and Template Method patterns?

Correct! Well done.

Incorrect.

The correct answer is A) Both patterns allow new behaviors to be added (via new strategy classes or overridden template steps) without modifying existing, tested code

A

Correct Answer

Both patterns allow new behaviors to be added (via new strategy classes or overridden template steps) without modifying existing, tested code

Explanation

Both patterns provide extension points (a new Strategy implementation, or an overridden template step) so that adding new behavior does not require modifying the existing class that uses them — the essence of OCP.

Progress
95/100