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

Give me example of chain of responsibility design pattern?

0 Answers  


What is the difference between 3 tier and n tier architecture?

0 Answers  


Can we inherit singleton class?

0 Answers  


Where should we use singleton design pattern?

0 Answers  


What are creational design patterns?

0 Answers  






How do you ensure quality of code ?

3 Answers   Infosys,


Are you using singleton in your code?

0 Answers  


What is software 'quality'?

2 Answers  


Is singleton scope thread safe?

0 Answers  


What are the additional productivity features and enhancements included with Quartus II software version 6.0?

0 Answers  


Suppose we have file(ps), dont know how many records are there. Move half of the records to 2 files. How can we do?

0 Answers  


What WYSIWYG web design tools are available?

1 Answers   HP,


Categories