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

What is the java virtual machine (jvm)?

0 Answers  


Sytem.out.println(" "); this code what mean

2 Answers  


What is lazy loading in jpa?

0 Answers  


What is the difference between collection and stream?

0 Answers  


What is the difference between deep copy and shallow copy in java

0 Answers   Amazon,


How do javabeans work?

0 Answers  


Iam working as a Project Lead in a s/w comp.The follwing question was asked in HCL interview. What about the schedule slippage? If the developer has taken more time than the specified time. How do you adjust the time? From where do you allocate that extra time for the developer?

2 Answers   HCL, Logesys,


What is meant by annotation in java?

0 Answers  


What is optional in java 8? What is the use of optional?advantages of java 8 optional?

0 Answers  


What is difference between loosely coupled and tightly coupled in java?

0 Answers  


What do you understand by a variable?

0 Answers  


What is adoptopenjdk?

0 Answers  


Categories