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

Quiz: Creational Patterns in Java · Question 6 of 10

A Factory method should usually return:

A Factory method should usually return:

  1. A.The common interface type, such as Payment
  2. B.The most specific class, such as CardPayment
  3. C.Object
  4. D.A String with the class name
Answer & explanation

Correct answer: The common interface type, such as Payment

Returning the interface lets callers stay independent of concrete classes.

Can you get the rest right without peeking?

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

Start the quiz →