Serialization example

Person2 is marked as Serializable interface. So writeObject and readObject methods will be called by compiler for serialization when writeobject method is invoked.