The readObject method either reads the information written by the corresponding writeObject method or can be used to update the state of the object after it has been restored. The writeObject method must be declared exactly as shown in the following example and should call the stream's defaultWriteObject as the first thing it does to perform default serialization. The readObject method must read in everything written by writeObject in the same order in which it was written. Also, the readObject method can perform calculations or update the state of the object. The writeObject and readObject methods are responsible for serializing only the immediate class.
Any serialization required by the superclasses is handled automatically.
However, a class that needs to explicitly coordinate with its superclasses to serialize itself can do so by implementing the Externalizable interface. Implementing the Externalizable Interface For complete, explicit control of the serialization process, a class must implement the Externalizable interface. For Externalizable objects, only the identity of the object's class is automatically saved by the stream. The class is responsible for writing and reading its contents, and it must coordinate with its superclasses to do so. It must implement a writeExternal method to save the state of the object.