Can we have a private constructor ?
Answer Posted / srikanth
We can make a constructor Private or protected.
1. Private constructor is classic example of implementing a
singleton class( A class with a single instance)
2. Protected constructors can be used when the class cannot
be instantiated but can only be inherited.
Is This Answer Correct ? | 108 Yes | 2 No |
Post New Answer View All Answers
What is the advantage of oop over procedural language?
What is destructor example?
Why we use classes in oop?
What is object and example?
Why do we use encapsulation in oops?
What do you mean by Encapsulation?
What makes a language oop?
What is purpose of inheritance?
What is overloading in oop?
What are the 3 pillars of oop?
What are the features of oop?
What are objects in oop?
What is overriding vs overloading?
What is the purpose of enum?
What is the main purpose of inheritance law?