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

Which design patterns have you used in your project ?

0 Answers   QuestPond,


What is synchronizer token pattern?

0 Answers  


Why should we not use singleton pattern?

0 Answers  


Give me example of chain of responsibility design pattern?

0 Answers  


What are sequence diagrams, collaboration diagrams and difference between them ?

8 Answers   ACET, CT, CTS, Infosys,


Where do you find inspiration and what are your long-term goals?

3 Answers  


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

0 Answers  


Which Design Patterns you know?

4 Answers   Honeywell,


What are the Design Patterns you know

4 Answers  


What is a lazy initialization in singleton?

0 Answers  


What are the types of participants of the prototype design pattern you will get?

0 Answers  


5.Develop an entity relationships diagram that identifies physical entity relationships.

0 Answers  


Categories