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

java - How to pass parameters between Request-Scoped Controllers? -

actionscript 3 - Flex: moving a point with rotation doesnt change the point XY? -

ms access - C# - Using OleDbParameter on table name -