← Quiz: Design Patterns: all 10 questions
Quiz: Design Patterns · Question 4 of 10
Why is a Singleton's constructor private?
Why is a Singleton's constructor private?
- A.To make it faster
- B.So other code can't create extra instances with new
- C.Because constructors must be private
- D.To allow inheritance
Answer & explanation
Correct answer: So other code can't create extra instances with new
Only the class itself can create its single instance.
Can you get the rest right without peeking?
Take the timed Quiz: Design Patterns quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →