Skip to content
Sharp

Design patterns · interview question

A developer argues that a new discount system for an e-commerce site should use static factory methods. What is a potential downside of this approach?

Multiple choiceHardchapter-13-curatedpremiumdesign-patternsfactory-pattern
Choose one answer
Answer and explanation

Correct answer

C. Static factory methods cannot be overridden in subclasses.

Why

Static factory methods cannot be overridden, which might limit flexibility if subclassing is needed in the future. Using the Factory Pattern allows for more dynamic object creation and easier extension.

Test yourself on Design patterns

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

Start free test
All Design patterns questions →