Java provides two different ways to allow a class to be serialized. The first is to implement the Serializable interface. This is just a marker interface, meaning it contains no methods. Java will also implement a serialVersionUID variable, although it is advised manual assign the variable. It is the unique identifier Java uses to tell which class it is reconstructing from a byte stream (more on this later).
This is the quickest and easiest way but gives you very little control over how the data is written. An implementation of Serializable with an example of a serialVersionUID variable.
Externalizable is an interface that extends Serializable. Unlike Serializable, Externalizable is not a marker interface. It requires an implementation of the methods readExternal() and writeExternal(). In addition
to these methods, the class must also have a default constructor. This is because when using readExternal() and writeExternal(), a constructor is actually called for the object and then its variables are updates. This allows for a faster execution time than Serializable. To implement readExternal() and writeExternal() manually write the variables of the class to the output stream given.
Core Java Interview Questions
Object Oriented Programming(OOP) Questions and Answers
Collections Interview Questions
Java Exceptions Interview Questions
Java Threads Interview Questions
Collection framework in java interview questions
oops concepts with example in java
Java Serialization Interview Questions
Top 20 Core Java Interview Questions with Answers
String Interview Question in java With Example
synchronization interview questions
Java Reflection Interview question
Java Executor Framework (JDK 1.5) Interview Questions
JDK 1.7 interview Questations and Answers
Java I/O interview question with example