Since transient and static not saved with serialized object, when deserialized ,the transient variable when recovred assumes null values that corresponds to data type.like for int its 0 ,if it was object reference ,it wold be null. If output of transient var was 7,as per your code,..that means transient var is also saved.which is nt possible
Thanks for the replies.I just have one more doubt.Lets say when transient,static variables are tried to serialize,then their default values are stored.Then the ouput of above program should be 10:0:10.How come its 10:0:10.Please help me.
we will never apply transient keyword to static and final variables. if you apply also there will be no effect on that variables. why because if you apply or not , it's actual value will be stored in the file.
where as normal variables if you apply transient keyword it will store default values instead of actual velue.
I am really not getting the point.Let me be more clear.In the above program,the output is "10:0:10".Please explain each ouput.Can we serialize static variable.I think its 'no'.please try to run above program.In the above program,if i change the 'static int to int',the output is "10:0:9".If 'int' can be serialized,Why is not "10:0:10".