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

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 Design Patterns you know

4 Answers  


What are the main usage of the patterns?

0 Answers  


Can we make the reference instance non static?

0 Answers  


What is the builder pattern?

0 Answers  






What is the executor design pattern?

0 Answers  


What is lexi design pattern?

0 Answers  


2. Create your own definition of a system. Based on the “system” definitions a. Identify your viewpoint of shortcomings in the definitions. b. Provide rationale as to why you believe that your definition overcomes those shortcomings. c. From an historical perspective, identify three precedented systems that were replaced by unprecedented systems.

0 Answers   IBM,


how many types of cookies in php

1 Answers  


When should design patterns be used?

0 Answers  


What is the use of such a class?

0 Answers  


What is Software development life cycle....??

5 Answers   TCS,


Categories