naveen yadav wrote:hi ranchers ,
a singleton class should have only one instance. It is quite possible to create a clone copy of singleton instance.which may break down the Singleton pattern.
Only if you make the Singleton class implement Cloneable, which would be kind of stupid. You can also end up with multiple instances by making the constructor public, or by having the getInstance() method create a new instance every time rather than returning the same one each time.
All of these have something important in common: They only let multiple instances exist if the author of the singleton class does something stupid. So write your singleton correctly, and the pattern won't be broken.
should a singleton class override a clone() method of object class ?
No. The only reason to override that method is if you're implementing Cloneable because you
want users of your class to be able to make copies of it.
(As a side note: Singleton is a vastly overused and much abused pattern, to the point where it's a good idea to make some effort to avoid it where possible.)