Hi. I think the answer to the following question is wrong (well... perhaps it's just because of the real odd wording). Could you please verify? --------------------------------------------------------------- (#223)TRUE of FALSE: in a switch statement, the argument to the case label (case: argument) can be any variable which can fit within an int. Answer: FALSE The case argument must be either an int literal, or an int-compatible variable which is a constant (i.e. static final). --------------------------------------------------------------- The question asks if the argument can be a variable, "which can fit within an int". This is definitely true! It does not ask, if it needs to be a VARIABLE (or if it can be something else like an int literal or constant). So in my opinion this either needs to have the answer changed or the word "variable" must be stressed in the question in order to set things right. Anyway... thanks for this really entertaining game ;) Daniel
Marilyn de Queiroz
Sheriff
Joined: Jul 22, 2000
Posts: 9033
10
posted
0
(#223)TRUE of FALSE: In a switch statement, the argument to the case label (case: argument) can be any variable which can fit within an int. Answer: FALSE The case argument must be either an int literal, or an int-compatible variable which is a constant (i.e. static final).
The key word is ANY variable. The argument to the case label must be a constant, either a static final (constant) variable or a literal. And, yes, the constant must also fit within an int (be int-compatible).
JavaBeginnersFaq "Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt