Intermediate Web & Software Development
Q76 / 100

What is the strategy pattern used for in object-oriented software design?

Correct! Well done.

Incorrect.

The correct answer is B) Defining a family of interchangeable algorithms or behaviors, encapsulating each one, and allowing the algorithm to be selected and swapped at runtime without changing the code that uses it

B

Correct Answer

Defining a family of interchangeable algorithms or behaviors, encapsulating each one, and allowing the algorithm to be selected and swapped at runtime without changing the code that uses it

Explanation

The strategy pattern lets you define several interchangeable behaviors (e.g., different sorting or pricing algorithms) behind a common interface, and choose or swap the concrete implementation at runtime — avoiding large conditional blocks and making new behaviors easy to add.

Progress
76/100