While reading a document on serialization i found that there are two call back methods readObject(ObjectInputStream) and writeObject(ObjectOutputStream) are present which are called by the JVM just before the object is serialized and deserialized.
I just wanted to know that when these call back methods are already present then why do we have need for Externalizable interface when we can do the same from these callback methods.
In the case of implementing Serializable interface,JVM does the serialization for us using readObject(ObjectInputStream) and writeObject(ObjectOutputStream) methods.
We may override these methods in the class being serialized to handle extra functionalities (like handling transient variables).We still have to call to call defaultReadObject () and defaulWriteObject () methods to get the actual object serialized/deserialized.
In the case of implementing Externalizable interface, we need to write code to save the contents... JVM won't do it for us.