What is singleton class?

Answer Posted / vimal eldose george

Singleton gives only one instance.

class Single{

static int objCreated = 0;
private Single(){
}
public static Single getThis(){
if(objCreated==0)
{
return new Single();
ob=1;
}else
{
return this;
}
}

}

Is This Answer Correct ?    32 Yes 17 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how come we know the object is no more used in the class?

6005


How to avoid memory leak in java?

849


What is primitive array?

694


What is instance synchronization?

830


Why stringbuilder is not thread safe?

785


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

817


Which is better list or arraylist in java?

666


What is stringjoiner ?

754


How do you use nextline in java?

715


How do you find the maximum number from an array without comparing and sorting?

886


What is set string?

797


How are the elements of a gridbaglayout organized in java programming?

748


What is parse method?

769


What is use of inner class in java?

761


Name container classes in java programming?

820