What is the singleton class in java?
Answers were Sorted based on User's Feedback
Answer / leelanarasimhareddy
A singleton is a class for which only one instance can exist
within a program. In other words, only one, single object of
that particular class can be created in a program.
Is This Answer Correct ? | 7 Yes | 0 No |
Answer / naman patidar
A singleton class can never have more then one instance.
Example :
class SingletonClass {
private static SingletonClass singleObject;
public static SingletonClass getInstance() {
if (singleObject == null) {
singleObject = new SingletonClass();
}
return singleObject;
}
}
Is This Answer Correct ? | 3 Yes | 2 No |
Answer / paletipatisrinu
singleton class:A java class create only one object per jvm
is called singleton java class.Most of jdbc driver class
implemented as a singleton java class
Ex:
class SingletonClass
{
private static SingletonClass singleObject;
public static SingletonClass getInstance()
{
if (singleObject == null)
{
singleObject = new SingletonClass();
}
return singleObject;
}
}
Singletone java class example is
org.apache.struts.action.ActionServlet
Is This Answer Correct ? | 2 Yes | 1 No |
When do we go for java 8 stream api? Why do we need to use java 8 stream api in our projects?
Does ms edge support java?
What is the content reside in Use case Document?
What is ehcache in java?
Can you compile java into exe?
What is Map,List,hashtable,ArrayList and difference between them??
What are the differences between java’s old java date api and java 8’s date and time api?
what is jdbc?
can anyone tell me what kind of questions are asked for core java exam in aptech
when Can an object reference be cast to an interface reference?
What is the difference between Enumeration and Iteration interfaces? What is the way of to retreive the objects from these interfaces ?
Is java an api?