java - Serializing an object which has a non-serializable parent class -



java - Serializing an object which has a non-serializable parent class -

how below code work?

class { int = 10; } class b extends implements serializable{ } public class test { public static void main(string[] args){ b obj = new b(); obj.a = 25; //code serialize object b (b b= new b()), // deserialize , print value of 'a'. } }

the code prints 10 though have changed value of 'a' in code.

any explanation behaviour ?

the default value of a 10 - set 10 when object created. if want have realistic test, set different value after instantiation , serialize it.

as update - if class not serializable, fields not serialized , deserialized. fields of serializable subclasses.

java serialization

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -