What is singleton class?

Answers were Sorted based on User's Feedback

What is singleton class?..

Answer / muthu

this is muthu,

i have created singleton class A this class file warped
(warfile) and same singleton class A that class also warped
(warfile)so both war file deployed inthe Application server
then start the server.so how many instance create in JVM?


Is This Answer Correct ?    0 Yes 0 No

What is singleton class?..

Answer / ashish srivastava

public class Singleton {

private static Singleton s = new Singleton();

private Singleton(){


public static Singleton getObject(){
return s;


Is This Answer Correct ?    0 Yes 0 No

What is singleton class?..

Answer / nagarjuna

Singletonclass is a class which can be instantiated only once.
public class Singleton
private static single = new Singleton();

Private Singleton();

For a singleton class, the constructor is made private and
a static variable is used for instatiating the class.

Is This Answer Correct ?    4 Yes 6 No

What is singleton class?..

Answer / ajay

how constructor can be private???????

Is This Answer Correct ?    0 Yes 2 No

What is singleton class?..

Answer / marshallsudhan

singleton class - has single Instance.

The Singleton is a useful Design Pattern for allowing only
one instance of your class, but common mistakes can
inadvertently allow more than one instance to be created.

The Singleton's purpose is to control object creation,
limiting the number to one but allowing the flexibility to
create more objects if the situation changes. Since there
is only one Singleton instance, any instance fields of a
Singleton will occur only once per class, just like static

//Eg Pgm.

class Sample
void m1()
System.out.println("Method m1");
void m2()
System.out.println("Method m2");
private Sample()
public static void main(String[] args)
Sample s = new Sample();

Is This Answer Correct ?    49 Yes 74 No

What is singleton class?..

Answer / ravikiran(aptech mumbai)

singleton class is the class contains only one object

Is This Answer Correct ?    39 Yes 71 No

Post New Answer

More Core Java Interview Questions

how to print a numbers from 1 to 100 with out using control structures?

4 Answers   IBM,

What are virtual methods?

1 Answers   TCS,

what is the reason behind non static method cannot be referenced from a static Context?

2 Answers  

The following program is Overloading or Overriding? public class PolymorphismEx { public int sampleMethod(int a) { return a; } public String sampleMethod(int a) { return "Is it Overloading or Overriding???"; } }

4 Answers   TCS, Ness Technologies,

where can we get jAVA project orientation traing in HYDERABD

0 Answers  

What are the OOPS concepts in Java ?

4 Answers   Satyam,

what is the diff b/w arraylist and vector?

6 Answers   Genesis, Sprintine Labs, Code Genesis,

relation between list and linked list

1 Answers   Infosys,

What is Servlet?

8 Answers  

Program to output as below formate: 1 2 3 4 5 6 7 8 9 10

4 Answers   Huawei,

What is Distributed Application and what is its usage?

2 Answers  

what is difference between abstract factory and factory design patterns?

0 Answers