Difference Between Serializable and Externalizable Interface in Java?

Serialization is the process using which you can save the state of the object do some other medium (secondary storage/over a network, etc). The precondition before an object state is saved is that is should implement the Serializable interface.
If we want to control the way in which the object is written , we will use  Externalizable interface.
Now having this little knowledge about serialization let us look what all are the differences between Serializable and Externalizable Interface.
  1. Serializable is a marker interface and Externalizable interface has methods which your implementation classes should provide.
  2. Serializable is the parent for Externalizable that is  Externalizable extends Serializable interface.
  3. Externalizable interface provides complete control over how the object should be written out , while serializable interface uses the default implementation to write the object.
  4. Externalizable interface provides more control over the read/write process by implementing the readExternal and writeExternal methods which are part of Externalizable interface while Serializable does not have any method.



Enter your email address to get our daily JOBS & INTERVIEW FAQ's Straight to your Inbox.

Make sure to activate your subscription by clicking on the activation link sent to your email