Serialization is a process of converting object into the stream .Stream is a flow of data in bytes ,Deserialization is the reverse process of serialization. Serialization is use to persist the data of the object so that exact object is reached to the end. Serialization is not applicable for all the class its costly concept it take more efforts by jvm and compiler so that data persist during networking for this we need to implement Serializable interface which is found in java.io; package the class which implements Serializable only those class object participate in the Serialization process.only those class objects data persist. Serializable is a marker interface . Marker interface are those interface which doesn’t have any methods .
Here string variable data will be persist if we transfer this object over the network because string class internally implements serializable interface.
If this class implements serializable then class Employee implements Serializable then and static variable not take parts in the process of serialization because static variable get memory before its object created. And if we use transient key word before any non static data member then its also not take part in the serialization process.or else every one participate in the process of Serialization.
Employee e = new Employee() ;
If we want to travel this object over the network then how we convert object into stream, object does’t have getBytes() method this is String class method then how to convert this object into stream?
To convert this object into Stream we have ObjectInputStream nad ObjectOutputStream in java.io package. We create object of this Stream classes and call write and read method to get and send data.