🎙 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 7 of 10

With 3 optional coffee add-ons, how many subclasses would you need to cover every combination (including plain coffee)…

With 3 optional coffee add-ons, how many subclasses would you need to cover every combination (including plain coffee) without Decorator?

  1. A.3
  2. B.4
  3. C.6
  4. D.8
Answer & explanation

Correct answer: 8

Each add-on is either present or not: 2 × 2 × 2 = 8 combinations.

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 →