Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


when we create singleton design then we create private
constructtor..so how JVM take private constructor to make
object..but it's private..



when we create singleton design then we create private constructtor..so how JVM take private constr..

Answer / pals

-Singleton design implies only 1 instance of a class can exist
-Private constructor implies only that class's member variables can call the constructor(Create an object)
-So a singleton class will have a private constructor only when you want to create ONLY 1 instance of the class without giving any other class the opportunity to create the class's objs using "new"; so you will have to write a static method in which u create an instance of this class and using this static method expose the reference of this object to the calling classes.So this will make sure that every user will use the same instance of the class.
Summary: JVM lets ONLY the private constructor class's members create only 1 obj of this class and lets other uses use this obj only by exposing a public static method.
I hope this is clear :)

Is This Answer Correct ?    21 Yes 0 No

Post New Answer

More Core Java Interview Questions

Is java same as core java?

0 Answers  


Is there is any difference between a scrollbar and a scrollpane?

0 Answers  


What is meant by JVM ?

6 Answers  


1).what is the difference between below examples String s="vijay"; String s=new String("vijay");

12 Answers   Mascon, Satyam, TCS,


What is assembly condition codes?

0 Answers  


Is set ordered?

0 Answers  


Using callable statement how can you pass out parameters, explain with example?

0 Answers  


What about method local inner classes or local inner classes in java?

0 Answers  


What is the return type of readLine() when end of a file is reached?

2 Answers  


Can a double value be cast to a byte?

3 Answers  


What is literal example?

0 Answers  


What's the purpose of static methods and static variables?

0 Answers  


Categories