Java Externalizable Interface

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

What is transient and volatile modifiers?
When serializable interface is declared, the compiler knows that the object has to be handled so as so be able to serialize it...
Java daemon threads: What are daemon threads?
Java daemon threads - Threads that work in the background to support the runtime environment are called daemon threads...
What is JAVAdoc utility?
Javadoc utility enables you to keep the code and the documentation in sync easily. The javadoc utility lets you put your comments...
Post your comment