• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SCJP Java 6 Sierra/Bates question on chapter 6 question 8

 
Scott Hughes
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am confused about the answer to this question.

The program has a serializable object with a static variable with a value of 9. It writes and object, closes it, and then adds 1 to it so the value is 10. However, when reading the input stream into a new variable, the value is still 10. My assumption was that it was written as 9 and the add occured after the write so the read on the other end would not have the value of 10 (9 was the value stored). However, the result says the answer should be 10.

Can someone please clarify my misunderstanding?

Thanks.
 
Rafael Angarita
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure, but I think you are talking about this: click here

Cheers,
 
James Tharakan
Ranch Hand
Posts: 580
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Static variables are not serialized...
 
Scott Hughes
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks very much!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic