What is the Externalizable interface?

The Externalizable interface is used to provide a complete control over the serialization and deserialization processes.This interface has the following two methods:

  • public void writeExternal(ObjectOutput objout): This method is used to save the contents of an object by calling the methods of the DataOutput interface for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, arrays, etc.
  • public void readExternal(ObjectInput objin): This method is used to restore the contents of an object that was saved using the writeExternal() method. It calls the methods of the DataInput interface for primitive types and the readObject() method for objects, strings, arrays, etc.
  • Share/Bookmark

Abstract class: In java, an abstract class is a class that is partially implemented. It provides design convenience. An abstract class is made up of one or more abstract methods that are declared but left unimplemented.

Interface: An interface is a reference type that defines a contract. An interface body consists of method declarations and constants. All methods and constants in an interface are public. Interfaces are left completely unimplemented, i.e., no method in the interface is implemented. All methods of an interface are abstract and the method body is absent.

  • Share/Bookmark