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 singleton a design pattern?

599


What is use case in clean architecture?

617


Write the code for a singleton class?

620


What is the executor design pattern?

727


What is proxy in design pattern?

610






Hi, I have 9backlogs in btech and i am 2008 passed out,am working with an MNC from past 3 years.now, am willing to do MS, will it be any problem for me?

2695


What are the most important software design patterns?

615


What is the difference between adapter and facade?

633


Are singletons bad?

578


Can you explain singleton pattern?

572


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

2447


What is the use of design patterns?

594


How do you choose a design pattern?

562


Describe the builder design pattern

665


Give me example of chain of responsibility design pattern?

623