aspose file tools*
The moose likes Mock Exam Errata and the fly likes java ranch #223 and #325 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Mock Exam Errata
Bookmark "java ranch #223 and #325" Watch "java ranch #223 and #325" New topic
Author

java ranch #223 and #325

val doty
Greenhorn

Joined: May 09, 2001
Posts: 1
I know that #223 has been discussed before, but I'm having trouble distinguishing the subtle differences that make these questions have different answers. Can someone explain this to me?
#223: In a switch statement, the argument to the case label (case: argument) can be any variable which can fit within an int. Answer: FALSE
#325: In a switch statement, the argument to the switch ( ) can be a variable as long as it is compatible with an int. Answer: TRUE
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
The argument to a case label can not be a variable... it must be a constant.


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Rebecca Mathew
Ranch Hand

Joined: Nov 23, 2000
Posts: 30
#223: .......the argument to the case label (case: argument) ....
#325: .......the argument to the switch ( ) .....
Val, do you notice the difference, in Q#223 it asks about the argument for the case-label, which like Thomas Paul said has to be a constant
whereas in Q#325, it asks about the argument for switch(), which can be any variable as long as it is compatible with int.
Hope this helps.
Haining Mu
Ranch Hand

Joined: Jun 01, 2001
Posts: 51
my other thought:
for case label, it can be CONSTANT VARIABLE if there is one, e.g.

but, it can not be a variable just fit in an int. If the switch argument is a byte, then case label 128 will be an error.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: java ranch #223 and #325