This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I would say B, not D. Although a transient static or final variable may not make sense, it shouldn't be prohibited. Afterall, transient only really becomes important with persistance and serialization classes.
However, the native keyword quite obviously violates platform independence; it requires a dynamically loaded library to be written in native code. This library limits the platforms on which the Java program will work.
Joined: Mar 05, 2006
Originally posted by Scott Hemsley: and why?
a)Transient methods must be static. b)Native methods violate Java�s platform independence. c)Static methods cannot be protected. d)Transient variables may not be final or static.
However, there is a common misconception among the community that would compel many to suggest b), therefore, if you are in an exam, I would answer b) based simply on the fact that the misconceptions that lead to the other answers are less prolific and therefore, less likely.
This is exactly the principle that I used for SCJP 5.0 i.e. thinking in terms of "what Sun want me to think", not "what is correct". It is very important to distinguish between these two, especially where there is a commercial interest (e.g. reading a technical book, doing an industry exam) or plain general misunderstanding or a "sheep following" (e.g. academia).
I proclaim neutrality and no other agenda but to portray fact as best as possible (Goedel's incompleteness, that I am human, etc. withstanding), but that doesn't stop me from being wrong sometimes Only that I like being wrong, since it contributes to my objective as opposed to the impact of being wrong when there is some other agenda. I certainly know what the Java platform is though, since it was once (and no longer is yay!!) my job to implement the thing