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 real life example of polymorphism?
What is difference between inheritance and polymorphism?
Explain the advantages of inheritance.
What is encapsulation and abstraction? How are they implemented in C++?
What is overloading in oops?
Can static class have constructor?
How can you overcome the diamond problem in inheritance?
What is difference between pop and oop?
What is polymorphism explain?
Can a destructor be called directly?
What is static in oop?
What does sksksk mean in text slang?
What is coupling in oop?
Why do we use polymorphism?
Why is encapsulation used?