Friday, August 9, 2013

Serialization Vs Extranalization

Serializable is a Marker Interface,is empty interface means it doesn't contain any fields and methods.Marker interface give special ability to Java object at run time  by using Serialization,we can save or transfer state of on object by converting it into a byte Stream.If java class implements Serializable interface then JVM treats this class object as Serializable object.

Externalizable  is a Interface and it is a sub interface of Serializable interface.Externalizable gives capability to programmers to create rules and own mechanisms.It has two methods,are writeExternal() and readExternal().

Serialization Vs Externalization:

1. Serialization is used for default serialization.While Externalization is used for customized serialization process.

2. We can use readObject() and writeObject() of serialization for store object  into persistence or re-getting object from persistence.But in Externalization,we can use readExternal() and writeExternal() methods for store object  into persistence or re-getting object from persistence. 

3. In Serialization, control is under JVM,while in Externalization control in programmer hands.

4. In deserialization process no constructor called in Serialization interface and default constructor is called in externalization at time of deserialization.


No comments:

Post a Comment