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

what are design patterns..?what design patterns used in .net.

1 Answers  


Is singleton scope thread safe?

0 Answers  


What are actually Model,view,Controller in MVC Pattern?

2 Answers   Honeywell,


what is MVC Pattern?

3 Answers   Honeywell,


What are the benefits of the proxy in the design pattern?

0 Answers  






What is a lazy initialization in singleton?

0 Answers  


In which application lifecycle phases is an application architecture produced?

1 Answers   Microsoft,


What is a behavioral design pattern?

0 Answers  


What is the use of such a class?

0 Answers  


What is onion architecture?

0 Answers  


What is grouping in CSS?

1 Answers  


what is data access layer?

7 Answers   Honeywell,


Categories