aspose file tools*
The moose likes Beginning Java and the fly likes Which of the Following is True? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Which of the Following is True?" Watch "Which of the Following is True?" New topic
Author

Which of the Following is True?

Scott Hemsley
Greenhorn

Joined: Mar 05, 2006
Posts: 7
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.

Thanks


Will I ever understand?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Well, not to be too Rogerian about it, but... what do you think the answer is?


[Jess in Action][AskingGoodQuestions]
Scott Hemsley
Greenhorn

Joined: Mar 05, 2006
Posts: 7
d) But the person who assited me with the answer was unsure why?
He also suggested maybe b)
Jeremy Tartaglia
Ranch Hand

Joined: Mar 11, 2004
Posts: 62
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.
Scott Hemsley
Greenhorn

Joined: Mar 05, 2006
Posts: 7
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.

Thanks
The answer is b) and d).

I missed the instruction "Choose more than one" .

Thanks to those who responded.
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
Why d?

This compiles with no problem.

Scott Hemsley
Greenhorn

Joined: Mar 05, 2006
Posts: 7
I don't know, I only got the answer not the explanation.

BTW, What is the purpose of Transient variables?
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
When an object of a Serializable class is written out to a file, any field marked transient will not have it's value stored as part of the object.
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
e) Boxcar Willy is a transient.


There is no emoticon for what I am feeling!
Tony Morris
Ranch Hand

Joined: Sep 24, 2003
Posts: 1608
e) none of the above

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

Good luck.


Tony Morris
Java Q&A (FAQ, Trivia)
Ken Blair
Ranch Hand

Joined: Jul 15, 2003
Posts: 1078
Originally posted by Scott Hemsley:
I don't know, I only got the answer not the explanation.

BTW, What is the purpose of Transient variables?


If they can't explain the answer then what good is it?
Scott Hemsley
Greenhorn

Joined: Mar 05, 2006
Posts: 7
Originally posted by Ken Blair:


If they can't explain the answer then what good is it?

OK.

I think the key to the answer d) is the wording.

d)Transient variables may not be final or static.

"May not be" not "Must not be". It is saying they don't have to be final or static.
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
I'm not sure. I took it to mean that a transient variable could not also be declared static nor final.
Scott Hemsley
Greenhorn

Joined: Mar 05, 2006
Posts: 7
Me too.

Thanks for your help, anyway.
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
I don't want to feed on anyone's conspiracy theories but last night a Prius pulled past me and I could have sworn James Gosling was driving and that Dick Cheney was riding shotgun!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Which of the Following is True?