What is singleton class?

Answers were Sorted based on User's Feedback

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

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

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

Answer / ajay

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

Is This Answer Correct ?    0 Yes 2 No

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

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

What is meant by class loader and how many types are there?

2 Answers   Apple,

I have a Arraylist object, it has duplecate values also. Now question is i want delete duplecate data in that objet with out using Set?

8 Answers   Aricent,

What is the return type of read()?

3 Answers  

write a program to create an vector with string(add,remove) operation.and value should be enter through keyboard.

0 Answers   Axcend,

1).Is Object class abstract or not? 2).Is main method(public static void main(String args[])low priority thread or high priority thread?

3 Answers   TCS,

we cannot create an object of interface but we can create a variable of it

1 Answers  

Difference between Primary key and unique key?

4 Answers  

What is the diff. b/w Interfaces & Abstract class?

6 Answers   Ericsson,

use of wrapper classes?

3 Answers   IBM,

what is the diffrences between platform independent and portable

5 Answers   TCS,

What are Access Specifiers and Access Modifiers.

6 Answers   TCS,

How does JAVA ClassLoader work?

1 Answers   IBM,