Home > DeveloperSection > Interviews > Where and how can you use a private constructor in java?

Posted on    April-10-2014 11:22 PM

 Java Java 
Ratings:
 1 Answer(s)
  1124  View(s)
Rate this:

Sumit Kesarwani

Total Post:782

Points:3910
Posted on    April-10-2014 12:00 AM

 Private constructor is used if you do not want other classes to instantiate the object and to prevent sub-classing. The instantiate is done by a public static method (i.e. a static factory method) within the same class.


Don't want to miss updates? Please click the below button!

Follow MindStick