~WOak
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Wilson Oak wrote:
public class Test {
public static void main(String[] args) throws Exception, IOException {
Dog obj = new Dog();
obj.num = 1;
obj.dogNum = 2;
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("test"));
oos.writeObject(obj);
ObjectInputStream ois = new ObjectInputStream(new FileInputStream("test"));
System.out.println("from main: " + ois.readObject());
}
}
OCPJP 6
Vinoth Kumar Kannan wrote:
I dont understand this...with just calling ObjectOutputStream's writeObject and ObjectInputStream's readObject, mustn't the output just be num = 1 & dogNum = 2 ?? I seriously am not getting this..
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Henry Wong wrote:
Not all objects are serializable. Not all objects are serializable correctly. In this case, the class provides readObject() and writeObject() methods, which will be called during serialization, which incorrectly serializes the object.
OCPJP 6
Vinoth Kumar Kannan wrote:
The Serializable interface defines no methods on its own. Then how come it is automatically going to call readObject() and writeObject() private methods on serializing?
~WOak
~WOak
It runs on an internal combustion engine. This ad does not:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|