If Super class is Serializable:
If super class is Serializable than all its sub-classes will be serializable by default. No need to implement the serializable interface in subclass explicitly.
If Superclass is not Serializable but subclass is:
If the superclass is not Serializable than to serialize the subclass’ object we must implement the serializable interface in subclass explicitly. In this case, the superclass must have a no-argument constructor in it.
If the superclass is serializable but we don’t want the subclass to be serialized:
To prevent a subclass from being serialized we must implement writeObject() and readObject() method and need to throw NotSerializableException from these methods.
Sometimes we need to extend a class that doesn’t implement the Serializable interface.
If we rely on the automatic serialization behavior and the superclass has some state, then they will not be converted to stream and hence not retrieved later on.
This is one place, where readObject() and writeObject() methods really help. By providing their implementation, we can save the superclass state to the stream and then retrieve it later on.