Man preet wrote:I think A and C are also valid . please explain this how D is correct!!Object serialisation
Hi Man, Only D is correct Option!
reason: when you implement writeObject,
you should implement readObject also, in case you are using other than defaultWriteObject method. otherwise when you deserialize you get a StreamCurruptedException. but you can use writeObject and writeInt after the defaultWriteObject method i.e,
So, I use always implement both the mothds(read/writeObject) . If you implement any one of them then you must call defaultWriteObject as a first statement.