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

When do we go for java 8 stream api? Why do we need to use java 8 stream api in our projects?

0 Answers  


Does ms edge support java?

0 Answers  


What is the content reside in Use case Document?

0 Answers  


What is ehcache in java?

0 Answers  


Can you compile java into exe?

0 Answers  


What is Map,List,hashtable,ArrayList and difference between them??

0 Answers   Cap Gemini, TCS,


What are the differences between java’s old java date api and java 8’s date and time api?

0 Answers  


what is jdbc?

6 Answers   Cap Gemini,


can anyone tell me what kind of questions are asked for core java exam in aptech

0 Answers  


when Can an object reference be cast to an interface reference?

1 Answers  


What is the difference between Enumeration and Iteration interfaces? What is the way of to retreive the objects from these interfaces ?

1 Answers   Cap Gemini,


Is java an api?

0 Answers  


Categories