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...


what is the use of declaring constructor as private?

Answers were Sorted based on User's Feedback



what is the use of declaring constructor as private?..

Answer / ranganathkini

By declaring the class constructor as private, other classes
cannot create instances of the class.

This design is usually used in singleton patterns.

Is This Answer Correct ?    22 Yes 2 No

what is the use of declaring constructor as private?..

Answer / ranganathkini

By making all the constructors of a class private, you can
also prevent other class from extending the class without
marking the class final.

Is This Answer Correct ?    9 Yes 6 No

what is the use of declaring constructor as private?..

Answer / suganya

prevent to access by other class even sub class cant have
permission to create object of that base class.

Is This Answer Correct ?    3 Yes 0 No

what is the use of declaring constructor as private?..

Answer / ravikiran

In order to restrict the class to get subclassed

Is This Answer Correct ?    6 Yes 6 No

what is the use of declaring constructor as private?..

Answer / anshul

A private constructor is a special instance constructor. It is commonly used in classes that contain static members only. If a class has one or more private constructors and no public constructors, then other classes (except nested classes) are not allowed to create instances of this class.

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More Core Java Interview Questions

How to make class immutable

6 Answers  


What are the notations in Java?

1 Answers   Cap Gemini,


What is the default value of the local variables?

0 Answers  


Why javac is not recognized?

0 Answers  


What is a local, member and a class variable?

0 Answers  


What is an example of a conditional statement?

0 Answers  


whats is the use of final,in which situation final can be used in the application?

2 Answers   DNS,


what is meant by Garbage collection?

0 Answers   Cap Gemini,


java Api provided try catch finally ,try catch(its ok) but why try finally and exception occured at try then how the flow is?

1 Answers   Naaptol,


If I only change the return type, does the method become overloaded?

0 Answers  


Is ++ operator is thread safe in java?

0 Answers  


How many digits is int32?

0 Answers  


Categories