Hi
I think we are running this Serialization example in incorrect fashion.
So, reason why change in value of 'z' is getting reflected after deserializing a class is because we are executing serialization and deserialization process from within same main
thread.
Since it is same thread , so , when we are changing value of 'z' after serialization , we are changing value of 'z' at class level which is being persisted by JVM because 'SpeicalSerial' class exists in JVM.
Afterwards , we are deserializing it and printing the value of 'z' , JVM takes out the value of 'z' stored at class level and prints it .
I have tried running this example by breaking Serialization and deserialization process in two classes
=====
Class A gives me output as 10
Class B gives me output as 0 9
Normally for running sample code regarding Serialization , we tend to do serialization and de-serialization within same main thread.
But in actual code , written for any application , we use to do serialization and de-serialization in two different classes. after all, that's what serialization concept is all about.
I hope this explains ..........
Oracle certified JPA Developer (1Z0-898),Oracle certified Java 8 Programmer I (1Z0-808), Oracle Java Web Service Developer (1z0-897), Oracle certified Java 7 Programmer, SCJA 1.0, SCJP 5.0, SCWCD 5.0, Oracle SQL Fundamentals I, CIW Certified Ecommerce specialist