Jim,
1) yeah, what she said.
2) &, ^, and | are defined for boolean types so:
boolean x = true;
boolean y = false;
System.out.println( "" + ( x ^ y ) );
does compile (and run).
The problem for me is that when the question is framed as:
x = true;
y = false;
What is x ^ y?
and the answers are:
a) won't compile
b) false
c) true
How do you decide what they are testing you on?
(1) whether ^ is defined for boolean types (it is)
(2) what ^ means (XOR)
(3) whether x ^ y is legitimate (it is because XOR is defined for boolean types or it isn't because you have to assign the operation to something: x ^ y; by itself won't compile)
(4) whether assignment is possible without declaration (it isn't).
(4) was the least likely and the one I chose, quite stupidly, in retrospect. It was highly unlikely that that was the purpose of the question.
Howver, a similar problem crops up with the question: TRUE or FALSE: you can pass a double type to a method that takes a float type as an argument. To which I reply,
FALSE - if the double is not cast to a float
TRUE - if the double is cast to a float
The correct answer was TRUE (which I simply guessed that they were assuming you would cast it) but this kind of question still worries me--I know what I know but how do I know what I know won't trip up me proving what I know?
Your comments are somewhat reassuring which was the main thing I thing I was looking for by posting.
I like to know why I am getting questions wrong (1) I don't know the material, (2) I'm not reading the question carefully enough [happens all the time, "reading" overloading instead of overriding is my favorite
], (3) the question is ambiguous--if the question had provided one more jot or tittle of information, I would have answered it correctly. (1) and (2) are definitely my fault but (3)? Well, I'm not a mind reader much less a Borg--although I have been accused.
Thank you for your kind attention.
Steve
sgwbutcher@aol.com [This message has been edited by Steve Butcher (edited April 05, 2000).]