Difference between Externalizable vs Serializable in Java

Knowing the difference between Externalizable vs Serializable is important in two aspects, one – if could be asked as an interview question, two – you can use the knowledge to make better informed decision for performance improvement for applying serialization into your application.

1. Differences between Externalizable vs Serializable

Let’s list down the main differences between Externalizable and Serializable interfaces in java.

Serializable is a marker interface i.e. does not contain any method.
Externalizable interface contains two methods writeExternal() and readExternal() which implementing classes MUST override.
Serializable interface pass the responsibility of serialization to JVM and it’s default algorithm.
Externalizable provides control of serialization logic to programmer – to write custom logic.
Mostly, default serialization is easy to implement, but has higher performance cost.
Serialization done using Externalizable, add more responsibility to programmer but often result in better performance.
It’s hard to analyze and modify class structure because any change may break the serialization.
It’s more easy to analyze and modify class structure because of complete control over serialization logic.
Default serialization does not call any class constructor.
A public no-arg constructor is required while using Externalizable interface.

Please note that Externalizable interface is child interface of Serializable i.e. Externalizable extends Serializable. So if any class implements Externalizable interface and override it’s writeExternal() and readExternal() methods then first preference is given to these methods over default serialization mechanism provided by JVM.

Read More : How to override default serialization mechanism in java

2. Read More about Externalizable and Serializable

Drop me your questions in comments section related to Externalizable and Serializable interfaces in Java.

Happy Learning !!

Was this post helpful?

Join 7000+ Awesome Developers

Get the latest updates from industry, awesome resources, blog updates and much more.

* We do not spam !!

0 thoughts on “Difference between Externalizable vs Serializable in Java”

  1. if there are large no of member variables , which needs not to be serialized then is there any other way other thann making it transient.?


Leave a Comment


A blog about Java and related technologies, the best practices, algorithms, and interview questions.