Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Questions from Complete Java 2 Certification

 
Snylt Master
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ranchers!
I have a questions that I can't understand on my own. Maybe there's a sheperd out there who can show me the way?
Question // I don't understand what the question means!!

Which modifier or modifiers should be used to denote a variable that should not be written out as part of its class's persistant state( Choose the shortest possible answer ).
// What does class's persistant state means?
A. private
B. protected
C. private protected
D. transient
E. private transient

Thanks!

------------------
Preparing for the Java 2 Certification exam
 
Dennis Hicks
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

An instance of a class can have its state (all the values of its' member variables) written to permanent storage - a process known as serialization (can't get used to that z!).
So when it says 'persistent state' it simply means the state of the object that survives and can be recreated from the serialized representation of the class.
Member variables marked as transient are not included when the object is serialized - the values of these are lost. One assumes they will be given the appropriate default values when the class is recreated.
So, the answer to you question is to declare the variable as transient.
Cheers,
Den
 
Snylt Master
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Dan for clearing this out for me
Regards
// Snylt Master
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic