While studying serialization in Java I came across this statement "while serialization the whole object graph of object is written to the stream" .So what if there is cycle in object graph ? What happens while deserialization in this case and why ?
Java Serialization handles cyclic object graphs via a 'handle' system. A previously serialized object is not re-serialized: instead, a 'handle ' to that object is serialized, which is reconstructed on deserialization to refer to the same object. See the Object Serialization Specification #1.2.