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 / ranganathkini

A Singleton is a class which at any given time has only one
instance and it does not allow more instances to be created.
Such classes do not have an accessible constructor, for example:

public class Singleton {
// class is automatically instantiated when the
// class is loaded
private static Singleton instance = new Singleton()

// constructor is made inaccessible by declaring
// it private
private Singleton() { ... }

// Access to the single instance of the class is
// provided by a static accessor method
public static Singleton getInstance() {
// returns a reference of the private instance
return instance;
}

// rest of the class implementation
}

Is This Answer Correct ?    176 Yes 21 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What isan abstract class and when do you use it?

1521


What does serializing data mean?

901


What is indexof in java?

950


Is static variable stored in heap?

942


what do you understand by synchronization? Or what is synchronization and why is it important? Or describe synchronization in respect to multithreading? Or what is synchronization? : Java thread

892


What is the byte order of byte buffer?

958


What is the difference between java applets and applications?

1108


how to write a program for sending mails between client and server

2032


What if the main() method is declared as private? What happens when the static modifier is removed from the signature of the main() method?

1153


What are the procedures?

1012


Can we modify the throws clause of the superclass method while overriding it in the subclass?

1004


How do you check if two strings are equal in java?

975


what is use of functional interface in java 8?

983


What are variable arguments or varargs?

963


What is ellipsis in java?

1020