How many objects are created for a singleton class

Answers were Sorted based on User's Feedback



How many objects are created for a singleton class..

Answer / pushpa

one

Is This Answer Correct ?    10 Yes 1 No

How many objects are created for a singleton class..

Answer / rajani nagandla

The Singleton is a useful Design Pattern for allowing only
one instance of your class.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 fields.



Is This Answer Correct ?    7 Yes 1 No

How many objects are created for a singleton class..

Answer / sivadasan

Singleton class allows to create only one instance of the
class. But the other objects can inherit from it. Singleton
is a Design Pattern to restrict create more than one
instance of a class.

And

1. It ensures only one object created for a class
2. Provides global point of access.

Mostly it is used to create DB connections.

Is This Answer Correct ?    4 Yes 1 No

How many objects are created for a singleton class..

Answer / utkarsh verma

Some correction required in last solution

void main(){

Single *ptr = Single::Instance(); //The only way to
//instantiate

}

Is This Answer Correct ?    3 Yes 0 No

How many objects are created for a singleton class..

Answer / chaman

Is a design pattern that is used to restrict instantiation
of a class to one object.

Is This Answer Correct ?    3 Yes 1 No

How many objects are created for a singleton class..

Answer / suresh solomon

in clustered environment singletons will have as many instances as JVMs

Is This Answer Correct ?    4 Yes 2 No

How many objects are created for a singleton class..

Answer / utkarsh verma

c++ program to explain Singleton

class Single {

private:
Single(){} //Can't instantiate

public:
Static Single* Obj;
Static *Single Instance ()
{
if(Obj == NULL)
Obj = new Single();
return Obj;
}
}//End of class

Single * Single ::Obj = NULL;

void main(){

Single *ptr = Obj->Instance(); //The only way to instantiate

}

Is This Answer Correct ?    3 Yes 1 No

Post New Answer

More Core Java Interview Questions

What types of index data structures can you have in java?

0 Answers   Tech Mahindra,


What is getclass () getname () in java?

0 Answers  


What is method overloading in java ?

0 Answers  


What is exception handling in java?

0 Answers  


What is sleep method?

0 Answers  


How do you reverse a word in java?

0 Answers  


how can i connect to database in a applet ?

1 Answers  


What is natural ordering in java?

0 Answers  


when should you use stringbuilder class in a program?

0 Answers  


How to make a read-only class in java?

0 Answers  


What are access specifiers in java ?

0 Answers   Akamai Technologies,


I have a string like _a01_a02_a03_ and another string like _2_1.5_4_ as input.I want to extract a01,a02... to a string array and 2,1.5,etc to a double array with a01 corresponds to 2 and a02 to 1.5 etc. Need code in core java.. Can you do it?

1 Answers   Cognizant,


Categories