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 object in oops?
What are the two different types of polymorphism?
What is a class oop?
Why do we use polymorphism in oops?
What is class and example?
Templates mean
What is the difference between static polymorphism and dynamic polymorphism?
class type to basic type conversion
What is overriding vs overloading?
What is encapsulation in oops?
What are benefits of oop?
Can you explain polymorphism?
Why do we need polymorphism in c#?
What is Difference Between Inheritance and creating object and getting data? means Class A extends B{ B.getMethod();} (OR) Class A{ b obj=new B(); obj.getMethod(); }
What does it mean when someone says I oop?