aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Question on Flow Control - Switch Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Question on Flow Control - Switch " Watch "Question on Flow Control - Switch " New topic
Author

Question on Flow Control - Switch

Venkat Sidh
Ranch Hand

Joined: Sep 30, 2006
Posts: 61
Which of the following types cannot be used as argument to the switch-case statement?

Choice - A) float
Choice - B) int
Choice - C) char
Choice - D) long
Choice - E) enum
Choice - F) short
Choice - G) double
Choice - H) Integer
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

JLS - 14.11 The switch Statement.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Vaibhav Chauhan
Ranch Hand

Joined: Aug 16, 2006
Posts: 115
i think answer should be:

float,long,double.

Reason: all the data types that can be implicitly converted to int can be used for switch case. Integer is right answer only for java 5 because it allows autoboxing/unboxing.
Please correct me if i am wrong
Venkat Sidh
Ranch Hand

Joined: Sep 30, 2006
Posts: 61
You can't use Integer (Wrapper) in statement as a argument.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question on Flow Control - Switch