Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About serialization

 
jaman tai
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Class fields with the following modifiers will not be serialized

1. private
2. static
3. transient
4. protected

the answer is 2 and 3. i dont know why 2 is correct.
 
Gaurav Chhabras
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am not exact sure but it might be possible that static variables are class variables and they does not belong to any particular object, in serializatin we store the current status of the OBJECT and its related variables and as static variables are of CLASS not of OBJECT thsts why they arte not Serialized.

Hope it might help you out.

Regards

Gaurav
 
Chetan Parekh
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Gaurav Chhabras:
i am not exact sure but it might be possible that static variables are class variables and they does not belong to any particular object, in serializatin we store the current status of the OBJECT and its related variables and as static variables are of CLASS not of OBJECT thsts why they arte not Serialized.


True, static varibles / methods / blocks are belongs to class and they are not belongs to objects. Hence static varible can't be serialised.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic