← Quiz: Creational Patterns in Java: all 10 questions
Quiz: Creational Patterns in Java · Question 1 of 10
Why is a Singleton's constructor made private?
Why is a Singleton's constructor made private?
- A.To make object creation faster
- B.So that code outside the class cannot create more instances with
new - C.Because static methods cannot call public constructors
- D.To allow inheritance from the class
Answer & explanation
Correct answer: So that code outside the class cannot create more instances with new
Only the class itself can create the one instance.
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 →