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

Why does each Builder setter return this?

Why does each Builder setter return this?

  1. A.To create a new builder each time
  2. B.To return the finished object
  3. C.So calls can be chained: .email(...).hostel(true).build()
  4. D.Java requires setters to return a value
Answer & explanation

Correct answer: So calls can be chained: .email(...).hostel(true).build()

Returning the same builder lets you call the next method on it.

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 →