hi,
if i implement singleton
pattern, i will be doing something like this
public class Singleton{
private static Singleton obj;
private Singleton(){}
public Singleton getInstance(){
if(obj == null) obj = new Singleton();
return obj;
}
}
this is fine, but i was asked one question
if i serialize the object and then desrialize it, what will happen and how can i make sure that when after desrializing on a different jvm, my contructor call should not happen whrn i require the instance..
i know in serialization we have to explicitly serialize static objects, but even in that case i'm not sure hw my constructor call will not happen, because at the most, what i ll do is to serialize the variables definig state of the object and then restoring that state.
i'm somewhat stuck .