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

Why should we not use singleton pattern?

575


Why have we declared the instance reference volatile?

544


What are the most important software design patterns?

617


Write the code for a singleton class?

622


Why singleton beans are not thread safe?

579






What are the design patterns you know explain?

595


Give me example of chain of responsibility design pattern?

625


when performing a functional test on a phone calculator,if pressing on a button does not function what do i do next

6843


Are singletons bad?

582


What is the difference between adapter and facade?

633


Contact a system development program in your organization. Research how they analyzed their SYSTEM OF INTEREST (SOI), its OPERATING ENVIRONMENT, and their respective system elements. How was this analysis reflected in the SOI architecture?

3634


Which design pattern is mostly used in net?

582


What is singleton design pattern in java?

595


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

586


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

2030