Chapter 6, Question 8
The output of this program is
10 0 10
Before the values were written out, z was 9. Afterwards, it was incremented. Please remember that z is a static variable, meaning it belongs to the class definition, hence it doesn't get serialized.
In order to alter standard deserialization process, implement the readObject() method in SpecialSerial. This readObject() will call defaultReadObject().
Please see below code
Compile and run this code. Output will be:
10 7 10