When you serialize an object using serializable, apart from fields, all objects that belong to object map and that can be reached using instance variable will also be serialized.
- One thing we can do with Externalization is that you can store extra information into an object like static variables and transient variables or you can add more information if we have any business need.
- If you have Employee class and its superclass is the person then it will serialize all superclass objects (such as the person) until it reaches the "Object" class. JVM uses reflection when you use serializable which is quite slow. While serializing, information about class description which includes the description of its superclass and instance variable associated with that class also get stored in the stream. Again this is also a performance issue.
- Similarly, if Employee has an instance variable of address class then it will serialize the whole object map of address also. Do you really want this much overhead when all you want to serialize is empId and empName?