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 singleton class?

Answer Posted / srinivas pentakota

A singleton is an class that can be instantiated once, and
only once. This is a fairly unique property, but useful in a
wide range of object designs. Creating an implementation of
the singleton pattern is fairly straightforward - simple
block off access to all constructors, provide a static
method for getting an instance of the singleton, and prevent
cloning.


public class SingletonObject
{
private SingletonObject()
{
// no code req'd
}

public static SingletonObject getSingletonObject()
{
if (ref == null)
// it's ok, we can call this constructor
ref = new SingletonObject();
return ref;
}

private static SingletonObject ref;
}

Is This Answer Correct ?    27 Yes 14 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Define jit compiler?

1077


What is array pointers ?

993


How can you set the applet size?

1010


How do you access command-line arguments within the code?

1015


Why inputstreamreader is used in java?

967


What is the mapping mechanism used by java to identify IDL language?

973


Does windows 10 need java?

1015


How do you define a method?

941


What will happen when using pass by reference in java?

949


Differences between external iteration and internal iteration?

1101


How do you do a line break in java?

950


What is the hashcode () and equals () used for?

971


Is empty in java?

1005


If a class is declared without any access modifiers, where may the class be accessed in java programming?

1155


why java uses class level type casting ?

2622