Define the purpose of Externalizable Interface. The Externizable interface extends the serializable interface.
When you use Serializable interface, your class is serialized automatically by default. But you can override writeObject() and readObject() methods to control more complex object serialization process.
When you use Externalizable interface, you have a complete control over your class's serialization process.
The two methods to be implemented are :
- void readExternal(ObjectInput) - void writeExternal(ObjectOutput) Explain the concepts of Externalizable Interface. Serialization is the process of persistence the state of objects to the storage media for future retrieval. The classes for persistence are to implement the Serializable interface.
The Externalizable interface has two methods namely writeExternal() and readExternal() which are to be overridden for the purpose of object serialization process. Using Externalizable interface, the developers have the complete control over object serialization.
The writeExternal() method is used save the contents of an object by invoking writeObject() method of OutputStream class or the contents of primitive types by invoking the appropriate methods of DataOutput. For deserialization, the readObject() method of InutStream class or contents of primitive types by invoking appropriate methods of DataInput
|