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 |
What do you understand by casting in java language? What are the types of casting?
How do I enable jvm?
what are the different phases in delivering the project during development and maintenance?
What is the singleton class in java?
How does jpa repository work?
How the java is platform independent?
I have deployed a .war file in my application server comprising of struts and hibernate.If i want to change the "dialect" property of hibernate cfg file how can i change(I have only .war file)... Thanks in advance
What is jpa implementation?
What is persistence xml in java?
Can an application have multiple classes having main method?
In system.out.println(), what is system, out and println?
What is a context in java?