Skip to content
Sharp

Design patterns · interview question

How can the Strategy Pattern help in adhering to the Open/Closed Principle?

Multiple choiceMediumchapter-13-curatedpremiumdesign-patternsstrategy-pattern
Choose one answer
Answer and explanation

Correct answer

B. By allowing the introduction of new algorithms without modifying existing code.

Why

The Strategy Pattern allows new algorithms to be introduced without altering existing code, adhering to the Open/Closed Principle, which states that software entities should be open for extension but closed for modification.

Test yourself on Design patterns

A free test with instant, explained results. No account needed.

Start free test
All Design patterns questions →