What is meant by Object Serialization?

In General, Object Serialization refers to writing an object into a stream,you can consider a stream as a data structure used to store values. Mostly the stream used for object serialization is a FILE. The reverse process is called object deserialization i.e, reading the object from the stream.

Object serialization is useful when you want to store objects into a file like primitive data types are stored.

What do they actually meant by writing(storing) objects?

Are we really writing the objects in to a stream? The answer is certainly "no". Then what we are writing into a stream?.Actually we are writing the state of the objects,to put it simply

"we are storing the non-static and non-transientfields of the class in to an external file".

Non-static field:

You could have known that a Non-Static field is a field(or variable) which is not preceded by the static modifier.

For example, int a=10;

You could have asked why astatic field is not serialized by default?

The reason is " If there is a non-static field in your class,then each object that you would create will have their won copy of that field but on the other hand if there is a static field then it will be shared by each object". So ratherthan serializing a static field for each object they(Sun Microsystems) could have left that.

Non-transient field:

Similar to Non-Static field, here the field is not preceded by the transient keyword.What is its use? There are certain fields which cannot be serialized in java,and if you try to do so then Not Serializable Exceptionwill be thrown. So, in order to avoid this exception you have to use this keyword.

Now let's see how to serialize and deserialize the object. If you want to serialize an object you need to use the ObjectOutputStream class of the java.io package as follows,

When reading(or Deserializing) the object,"we are not actually reading the object, a new object is re-constructed from the stream with the field values stored in it". Here i would like to highlight one thing, you all know that to constructan object we need the class definitionand this applies even if you reconstruct the object i.e, when reading the object from the stream we need the actual class definition in the class path.