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

Why is the main method declared static?

571


Can we instantiate interface in java?

662


What is difference between arraylist and list in java?

572


What do you mean by ternary operator in java?

550


Is array primitive data type in java?

525






Is java call by reference?

523


Do I need java on my computer?

522


What is the difference between class & object?

547


When the constructor of a class is invoked?

580


Why is string builder not thread safe?

583


What does the string method compareto () do?

531


Can a hashset contain duplicates java?

489


what is the major difference between linkedlist and arraylist in java?

540


What is array class in java?

586


What are recursive functions?

567