What is the difference between Serializable and Externalizable interface?
java.io.Serializable interface is an empty interface with no methods and attributes.It is implemented by objects which are needed to be serialized and serves only to identify the semantics of being serializable.
When process of serializing an object is to be controlled then Externalizable interface is used.The Externizable interface extends Serializable and adds two methods,writeExternal() and readExternal() which are automatically called during serialization and deserialization.
Classes that require special handling during the serialization and deserialization process must implement special methods with these exact signatures:
private void writeObject(java.io.ObjectOutputStream out) throws IOException
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException;
When process of serializing an object is to be controlled then Externalizable interface is used.The Externizable interface extends Serializable and adds two methods,writeExternal() and readExternal() which are automatically called during serialization and deserialization.
Classes that require special handling during the serialization and deserialization process must implement special methods with these exact signatures:
private void writeObject(java.io.ObjectOutputStream out) throws IOException
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException;