🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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?

  1. A.Strategy
  2. B.Observer
  3. C.Builder
  4. 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 →