When should I use a singleton?



When should I use a singleton?..

Answer / Nikhil Kumar Karn

Use a singleton when you want to ensure that only one instance of a class is created. This is useful in situations where you have a global configuration object, a database connection pool, or a logger.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

What are the properties of thread?

1 Answers  


How many tetrahedral voids are there in bcc?

1 Answers  


what is servlet filter?

2 Answers  


If goto and const is reserve words than why it is not work in java?

1 Answers  


why java does not have operator overloading?

2 Answers  


What is the difference between Checked and Unchecked exception? Give some examples

2 Answers   Ness Technologies,


How does thread synchronization occurs inside a monitor? What levels of synchronization can you apply?

1 Answers  


4.1 Supply contracts (in the form of comments specifying pre- and post conditions) for the enqueue() method of the LinkedQueue class given in the Appendix. (2) 4.2 Let Thing be a class which is capable of cloning objects, and consider the code fragment: Thing thing1 = new Thing(); //(1) Thing thing2 = thing1; //(2) Thing thing3 = (Thing) thing1.clone(); //(3) Explain how the objects thing2 and thing3 differ from each other after execution of the statements. (

1 Answers  


What is the lifetime and scope of a variable?

1 Answers  


Can static methods be inherited?

1 Answers  


Is ++ operator thread-safe in java?

1 Answers  


What do you mean by exception handling in Java?

1 Answers   Atos Origin,


Categories