← 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?
- A.Inner classes cannot have constructors
- B.Static classes are thread-safe
- C.It makes the Pizza immutable by itself
- 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 →