Home > Software > Java > Core-Java
Interview Questions   Tutorials   Discussions   Programs   

Core-Java - What is private constructor? What are the uses of writing private constructor in our program?




372
views
asked marvit October 15, 2014 01:05 AM  

What is private constructor? What are the uses of writing private constructor in our program?


           

1 Answers



 
answered By   0  

-->A constructor using private modifier is called private constructor. -->if a constructor is declared as private constructor we can not create object of its class from outside the class. But we can create object of the class inside that class. Usage----------> The private constructor concept is very important in Design pattern. --->if you want to restrict the object creation of a class outside the class then we will declare the class constructor as private.

flag   
   add comment

Your answer

Join with account you already have

FF

Preview


Ready to start your tutorial with us? That's great! Send us an email and we will get back to you as soon as possible!

Alert