🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Design Patterns: all 10 questions

Quiz: Design Patterns · Question 3 of 10

A payment module must create a UPI, card or wallet object based on the user's choice, without if/else scattered everywh…

A payment module must create a UPI, card or wallet object based on the user's choice, without if/else scattered everywhere. Which pattern fits?

  1. A.Factory
  2. B.Observer
  3. C.Decorator
  4. D.Adapter
Answer & explanation

Correct answer: Factory

A factory centralises the decision of which class to create.

Can you get the rest right without peeking?

Take the timed Quiz: Design Patterns quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →