What is the singleton class in java?

Answers were Sorted based on User's Feedback



What is the singleton class in java?..

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

What is the singleton class in java?..

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

What is the singleton class in java?..

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

Post New Answer

More Java Related AllOther Interview Questions

How do I install java re?

0 Answers  


What's the difference between authentication and authorization? : java security

0 Answers  


how can we create the ui using netbeans,having the code?

0 Answers  


What is a yaml file in java?

0 Answers  


What is a service layer in java?

0 Answers  






What is a driver in java?

0 Answers  


What is the purpose of jdk?

0 Answers  


How to load a class programmatically?

1 Answers  


How do I open java console?

0 Answers  


Is lambda expression an object?

0 Answers  


What is type inference? Is type inference available in older versions like java 7 and before 7 or it is available only in java se 8?

0 Answers  


Can you compile java into exe?

0 Answers  


Categories