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
What are the object and class classes used for?
What happens when you add a double value to a string?
Can we use String with switch case?
When should a function throw an exception?
What is consumer interface?
Can a static member function access member variable of an object?
What is an object in java and how is it created?
What is generic class?
What is valid keyword in java?
how its run?
Why are lists ordered in java?
If an application has multiple classes in it, is it okay to have a main method in more than one class?
How do you achieve polymorphism in java?
What is a method header?
Explain the difference between collection api and stream api in java8?