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 private constructor?what are the uses of writing
private constructor in our program?

Answer Posted / ajay parashar

Private constructor is simple constructor that has private
access modifier.
Private constructors are used for two purposes.
1)to prevent creation of objects outside the class when
there are no instance variables in the class and the
methods of class takes some input parameters and does
processing and returns the result without getting or
setting instance variables like in math class of .NET.
2)When your application requires a class that has only one
instance and you need to provide a global point to access
that instance like in the case of singleton.

Is This Answer Correct ?    17 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is hotjava?

1011


What is difference between final and immutable?

1150


What is native method in java?

1065


What is a generic code?

1067


How many types of java are there?

982


What is Java Reflection API? Why it’s so important to have?

1166


Describe 2 different ways to concatenate two strings.

1206


What is singleton math?

1140


What causes memory leak in java?

938


What design pattern you have used in your project? I answered Factory pattern, how it is implemented? What are its advantage? Do know about Abstract Factory?

2507


What are the access modifiers in java?

1041


Explain Basics of OOP Language in java

1062


Can we declare register variable as global?

934


What is a treeset in java?

1043


What are the java ide's? Explain

1059