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 abstraction in oop?
Why do we use oops?
What polymorphism means?
What is object in oop with example?
What is difference between data abstraction and encapsulation?
What does and I oop mean?
What is object-oriented programming? Webopedia definition
Why interface is used?
Why is destructor used?
What is oops in simple words?
write a program to find 2^n+1 ?
What is interface? When and where is it used?
What is encapsulation with real life example?
What are the important components of cohesion?
What is a null tree?