← 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:
- A.The common interface type, such as
Payment - B.The most specific class, such as
CardPayment - C.
Object - 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 →