Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can Static and Transient appear together?

 
Monisha Talwar
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Whod Prompt
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic