Skip to content
Sharp

Design patterns · interview question

In a checkout system, which scenario best exemplifies the use of the Strategy Pattern?

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

Correct answer

C. Calculating shipping costs based on different carriers.

Why

The Strategy Pattern is ideal for scenarios where different algorithms can be interchanged, such as calculating shipping costs based on various carriers. This allows each carrier's algorithm to be encapsulated in its own strategy class.

Test yourself on Design patterns

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

Start free test
All Design patterns questions →