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

What is native method in java?

757


What will be the default values of all the elements of an array defined as an instance variable?

750


What is a conditional equation?

755


How can you handle java exceptions?

703


What is the importance of hashcode() and equals() methods?

769


Why call by value prevents parameter value change?

787


Can I declare class as static or private?

733


Explain the difference between comparator and comparable in java?

667


What is jdbc api?

727


What are the types of java?

767


Is java still relevant?

707


What is the private method modifier?

786


State some situations where exceptions may arise in java?

816


State two differences between C and Java.

912


Does java list allow null?

736