What is singleton class?

Answer Posted / sathya

Singleton class:
This is a class which can be instatiated only once.

Eg:

Public class Singleton
{
private static single = new Singleton();

Private Singleton();
{}
}

For a singleton class, the constructor is made private and
a static variable is used for instatiating the class.

Is This Answer Correct ?    242 Yes 44 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain the difference between abstraction and encapsulation.

535


How can you set an applet’s height and width as a percentage?

510


Does java vector allow null?

535


What is final access modifier in java?

586


How are observer and observable used in java programming?

539






Why is sizeof not a function?

541


What are local variables?

589


When do we use hashset over treeset?

528


How many types of constructors are used in java?

533


What is difference between array and vector?

529


Why scanner is used in java?

544


What does n mean?

517


Is it possible to override the main method?

529


What is the purpose of an interface?

550


What is the best definition for data?

517