Question OOP-CTOR-0011
MediumCan a constructor be private?
- A.
No, never
- B.
Only if the class has no fields
- C.
Sign up free to see the answer and a step-by-step explanation.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Constructors and Destructors question
Can a constructor be private?
No, never
Only if the class has no fields
Sign up free to see the answer and a step-by-step explanation.
Only in Python
Yes, e.g. to stop direct creation in the singleton pattern