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

Is oop a design pattern?

0 Answers  


how to pring 10 item per page in smartform

0 Answers  


What are the examples of the behavioral design patterns?

0 Answers  


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

0 Answers  


What is the publish/subscribe model?

1 Answers  


Is singleton an anti pattern?

0 Answers  


Give me example of observer design pattern?

0 Answers  


What is a pattern library?

1 Answers  


Why have we declared the instance reference volatile?

0 Answers  


What are the advantages of thin clients?

1 Answers  


Why should we not use singleton pattern?

0 Answers  


write 5 best test cases like any password?password should be mixed case with atlest one number or special characters?

2 Answers   Wipro,


Categories