How can we design/implement singleton object?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is mvc is a design pattern?

808


what are the creational design patterns

841


What are the categories in which the design patterns can be divided?

799


When should design patterns be used?

760


What non-visual coding tools are available for web design?

2299


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

803


Give me example of observer design pattern?

831


What is architecture and what is design?

797


What is the difference between factory and builder design pattern?

683


What is the use of repository pattern?

778


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

779


What is viper architecture?

776


What are useful tools for developing and testing color schemes for web sites?

2229


What is a behavioral design pattern?

809


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

2623