What is difference between using Serializable & Externalizable Interfaces in Java?

By | August 12, 2019

In this blog post we will talk about What is difference between using Serializable & Externalizable Interfaces in Java? One thing I would like to make you clear here is that this post only listed out the difference between using Serializable & Externalizable but not the detail explanation.

  1. Externalizable Interface extends the io.Serializable adding two methods – writeExternal & readExternal.
  2. In case of Serializable, default serialization is used, while in case of Externalizable, the complete serialization control goes to the application. Stating that means, we can not benefit from the default serialization process when we choose Externalizable
  3. We generally choose Externalizable when we want to save the output in our custom format which is other than Java default serialization format like, csv, database, flat file, xml, etc
  4. readExternel() and writeExternal() methods are used to handle the serialization in case of Externilizable
  5. In case of Serialization, object is reconstructed using data read from ObjectInputStream but in case of Externalizable, public no-arg constructor is used to reconstruct the object.

You may also like:

Why Java is not 100% Object-oriented language?
What are the differences between 32-bit and 64-bit versions of Java?
Can we call static method with null object?
Can we override static method in Java?
What will be the output of following java program?
What is the difference Between java.util.Date and java.sql.Date in Java ?
Why Prime Numbers are considered in writing certain algorithms like hashcode()?

That’s all about  What is difference between using Serializable & Externalizable Interfaces in Java?
If you have any feedback or suggestion please feel free to drop in blow comment box.

Leave a Reply

Your email address will not be published.