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

Quiz: Nested and Anonymous Classes · Question 10 of 10

In the Builder pattern, why is Pizza.Builder a static nested class rather than an inner class?

In the Builder pattern, why is Pizza.Builder a static nested class rather than an inner class?

  1. A.Inner classes cannot have constructors
  2. B.Static classes are thread-safe
  3. C.It makes the Pizza immutable by itself
  4. D.A Builder must exist before any Pizza object does, so it cannot need an outer Pizza
Answer & explanation

Correct answer: A Builder must exist before any Pizza object does, so it cannot need an outer Pizza

An inner class needs an outer object; the builder's job is to create that object.

Can you get the rest right without peeking?

Take the timed Quiz: Nested and Anonymous Classes quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →