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 implement Singleton

Answer Posted / hardeep thakur

Here is code to implement the singleton

public class SingletonClass {
private static SingletonClass singleObj ;
private SingletonClass(){}

public static synchronized SingletonClass getInstance()
{
if(singleObj ==null){
singleObj = new SingletonClass();
}
return singleObj;
}

public Object clone() throws CloneNotSupportedException
{
throw new CloneNotSupportedException();
}

}

Is This Answer Correct ?    7 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

In a class implementing an interface, can we change the value of any variable defined in the interface?

1034


What is a linkedhashmap java?

956


How we create object in copy constructor?

1075


What is instanceof keyword?

1173


Write down program for following scenario. Use java coding standard. You have array list with some words in it..we will call it as dictionary….and you have a arbitrary string containing some chars in it. You have to go through each word of dictionary and find out if that word can be constructed with the help of chars from arbitrary string given. If you find the word print it else print none.

2681


Write a program to print the pattern given below

894


What is the exact difference in between Unicast and Multicast object? Where will it be used?

1013


What is data type example?

913


What is a consumer in java?

970


What is array and arraylist in java?

1053


What is nested class?

952


What is the use of System class?

1105


What’s the difference between unit, integration and functional testing?

1054


How big is a gigabyte?

998


What does java stand for?

1048