How can we design/implement singleton object?

Answers were Sorted based on User's Feedback



How can we design/implement singleton object?..

Answer / ravi

Make the constructor private

provide a static synchronized method to get the Instance.

this should make the object singleton for that jvm instance

Is This Answer Correct ?    3 Yes 0 No

How can we design/implement singleton object?..

Answer / todd d. roling

public enum Singleton {
INSTANCE;
}

Is This Answer Correct ?    2 Yes 1 No

How can we design/implement singleton object?..

Answer / jayashri

by declaring the constructor as private and we have to create public static method which returns the address of single object.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Design Patterns Interview Questions

4. Identify and bound the SOI’s Operating Environment.

0 Answers  


Why is singleton used?

0 Answers  


Quartus II software version 6.0 is available for which operating systems (OS)?

0 Answers  


Can any one suggest me the best institute for Software Design , Design Patterns and architecture in Hyderabad please. Thanks in Advance.

2 Answers   IBM, KPIT,


Why singleton beans are not thread safe?

0 Answers  






Why is singleton bad?

0 Answers  


Shall we use abstract classes or interfaces in policy / strategy design pattern?

0 Answers  


Why is it important to use systems analysis and design methodologies when building a system? Why not just build the system in whatever way appears to be “quick and easy”? What value is provided by using an “engineering” approach?

1 Answers   DBU, KSV College, Sampson, University of Ibadan,


What are the examples of the behavioral design patterns?

0 Answers  


What is the prototype design pattern?

0 Answers  


What is the S/W model used in the project. What are the optimization techniques used. Give examples ?

2 Answers   Infosys, Symphony, Wipro,


what is a Design Pattern?

5 Answers   TCS,


Categories