Skip to main content

Posts

Showing posts from June 29, 2016

Serialization & Deserialization Concpets In Java

Serialization is required to save that particular state of instance/object so that it can pass that object over to network to some receiver where it could be deserialized.
By Default all java class is not serializable but we can make it by implementing serialization interface.It is  marker interface which tells JVM to treat that class for serialization.
objectOutputStream.writeObject();objectInputStream.readObject();

There are could scenarios possible while serialization with respect to inheritance.
1. Class which you want to serialize not having super class serializable.
    In this case we can serialize without any issue but we can loose setting values of  super class variables. As while deserialization constructors are not invoked generally for classes which are serializable but if classes which are not serializable (which is super class in this case) constructor will run for it & its all super classes. Due to this we will get default values rather then true values or state. Se…