This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes can a trasient member also b static ?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "can a trasient member also b static ?? " Watch "can a trasient member also b static ?? " New topic
Author

can a trasient member also b static ??

preethi subramaniam
Greenhorn

Joined: May 15, 2003
Posts: 3
Khalid says " transient modifier cannot be specified for static variables as they do not belong to objects " . But in one of the answers to mock test i found it can be given ? so can i b or it cannot b given ??
Lawrence Chettiar
Ranch Hand

Joined: Apr 10, 2003
Posts: 62
preethi
The answer to your question is it depends on the context of the question what I mean is yes you are right a static cannot be transient in other words or correct words a static will not be seralized any way hence use of trasient keyword is not needed hence in a way we can say that static cannot be transient BUT the compiler will not complain if you use transient for a static variable.
Hence if the question is asked as if there will be a compiler error then no it won't be which could be the context of the other question.
Hope it helped.
(see java.io.Serializable api doc it has good detail about this)


SCJP 1.4 (86%)<br />SCMAD Beta (77%)<br />SCEA (part I:89%,partII:93%)<br />MCAD (cleared 70-315 & 70-320 [Score 980])
Jessica Sant
Sheriff

Joined: Oct 17, 2001
Posts: 4313

whew -- I think I'm "hence" 'd out.
Check out our handy dandy search facility -- you'll find this has been asked a bunch.
Here's a couple to get you started:
transient static variable
transient + static
 
jQuery in Action, 2nd edition
 
subject: can a trasient member also b static ??