| Author |
Can Static and Transient appear together?
|
Monisha Talwar
Ranch Hand
Joined: Feb 11, 2003
Posts: 102
|
|
As per Mughals book, Pg.126, Chapter 4, it says: Note that transient modifier should not be specified for static variables, as these do not belong to objects. Then again on Page 130. Q4.26 is as follows: Which of these are not legal declarations within a class? (a)static int a; (b)final Object[] fudge = {null}; (c)abstract int t; (d)native void sneeze(); (e)final transient static private double PI = 3.141592653589793223846 I thought the answers would be (c) and (e). But the ans is just (c). I tried compiling it and it worked fine. So, I looked for errata in the book online (http://www.ii.uib.no/~khalid/pgjc/jcbook/errata.html), but could spot anything on this. Am I missing something?? So the "transient" and "static" keywords can be use together? Monisha.
|
Hey! It compiles! Ship it!
|
 |
Whod Prompt
Greenhorn
Joined: Mar 20, 2003
Posts: 10
|
|
wasn't sure myself, but searching found the answer here http://www.coderanch.com/t/143541/Mock-Exam-Errata/certification/transient-static
|
 |
Monisha Talwar
Ranch Hand
Joined: Feb 11, 2003
Posts: 102
|
|
Thanks. So I think its legal to have "static" and "transient" together, but it does not make sense to do that. I guess in the sentence
Note that transient modifier should not be specified for static variables, as these do not belong to objects. /QUOTE] the "Should not be" does not neccessarily mean "Can not be" :roll:
|
 |
 |
|
|
subject: Can Static and Transient appear together?
|
|
|