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

How to create an instance of a class if the class has
private constructor?

Answer Posted / eswar

u can create instance like this...

class Ex
{
public static Ex e=null;

private Ex()
{}

public Ex getObj()
{
if(e==null)
e=new Ex();
return e;
}
}

Actually the above coding is example for singleton Java
class.... which creates omly one object per JVM

Is This Answer Correct ?    6 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain features of interfaces in java?

995


What is composition in java?

1295


What is a method signature java?

1056


how to prepare for IT Officers Interview in Banks

1978


What is the purpose of using break in each case of switch statement?

1029


Which software is used for java programming?

1027


Is java call by reference?

982


Write a program to check string is palindrome without using loop?

1038


What class allows you to read objects directly from a stream in java programming?

1079


Is 9 a prime number?

886


How are this() and super() used with constructors in java programming?

1064


How many bits are used to represent unicode, ascii, utf-16, and utf-8 characters in java programming?

1018


Is array a class?

940


Is a boolean variable?

1016


Explain heap sort?

1125