File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes transient variable? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "transient variable?" Watch "transient variable?" New topic

transient variable?

srikanth reddy
Ranch Hand

Joined: Jul 28, 2005
Posts: 252
hi frnds

i have got a doubt regarding transient variable while reading Heller and Roberts book...

Which of the following statements is true?
A.Transient methods may not be overridden.
B.Transient methods must be overridden.
C.Transient classes may not be serialized.
D.Transient variables must be static.
E.Transient variables are not serialized.

here the answer given is E.i just wanted to know that why not transient variable be static and also i feel that they can be serializable .

please can anyone clear my doubt

thanks & regards


Thanks & Regards<br /> <br />-Srikanth
Santana Iyer
Ranch Hand

Joined: Jun 13, 2005
Posts: 335
transient can only be applied to variables,

transient keyword is used its meaning is that they are not to be serialized
read about it.
Will Fleming

Joined: Sep 28, 2005
Posts: 20
I think the key word in answer D is *must*.

You can, but you don't have to, thus the statement isn't true.

Thinking some more on it, I don't see why a static variable would be serialized anyway. The only thing that you would 'save' during serialization would be the instance variables.

Either way, D is not correct.

[ October 04, 2005: Message edited by: Will Fleming ]
[ October 04, 2005: Message edited by: Will Fleming ]

SCJP 1.5
I agree. Here's the link:
subject: transient variable?
It's not a secret anymore!