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 the use of jtable?

648


What is pojo class in java?

532


What is string and its types?

606


Where is core java used?

574


Write an algorithm program in java for the following question.. In a VLSI design techniques,they used rectangles to design circuits. EVery rectangle is to be placed according to x,y coordinates. Check whether or not two rectangles overlap each other. Here overlapping of rectangles is acceptable, if 1) one rectangle intersect with other. 2) one rectangle fully covers other. The time of algorithm should not exceed o(n logn).

2230






What modifiers may be used with a top-level class?

571


When will we use them?

586


What does this () mean in java?

539


What is matcher in java?

512


What is use of map in java?

507


What is the difference between integer parseint and integer valueof?

542


Explain a few methods of overloading best practices in java?

502


What is the Difference between Final Class && Abstract Class?

613


What is the method overriding?

614


What is instance synchronization?

539