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


Please Help Members By Posting Answers For Below Questions

What is the advantage of oop over procedural language?

835


What is destructor example?

770


Why we use classes in oop?

754


What is object and example?

869


Why do we use encapsulation in oops?

737


What do you mean by Encapsulation?

799


What makes a language oop?

812


What is purpose of inheritance?

835


What is overloading in oop?

755


What are the 3 pillars of oop?

845


What are the features of oop?

826


What are objects in oop?

816


What is overriding vs overloading?

778


What is the purpose of enum?

759


What is the main purpose of inheritance law?

925