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 does it mean when someone says I oop?
INSTANCE FIELDS DECLARED private ARE ACCESSIBLE BY THE METHODS ONLY.CAN WE CHANGE THE private FIELD OF AN OBJECT IN A METHOD OF SOME OTHER OBJECT OF THE SAME CLASS?
What is the real time example of encapsulation?
Is abstract thinking intelligence?
What is the benefit of oop?
What is the difference between encapsulation and polymorphism?
What is the example of polymorphism?
What does oop mean in snapchat?
What are the features of oop?
What is the real time example of inheritance?
Whats is abstraction in oops?
Following are the class specifications: class {int a}; class {int b}; Using friend funtion,calculate the max of two objects and display it.
What is pure oop?
What is a class and object?
When not to use object oriented programming?