← Quiz: Observer, Strategy and Decorator: all 10 questions
Quiz: Observer, Strategy and Decorator · Question 4 of 10
A canteen bill uses if (type == STUDENT) … else if (type == STAFF) …. Which pattern removes this chain?
A canteen bill uses if (type == STUDENT) … else if (type == STAFF) …. Which pattern removes this chain?
- A.Strategy
- B.Observer
- C.Builder
- D.Singleton
Answer & explanation
Correct answer: Strategy
Each pricing rule becomes its own class behind a PricingStrategy interface.
Can you get the rest right without peeking?
Take the timed Quiz: Observer, Strategy and Decorator quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →