Switch statements Flashcards
1
Q
what 3 data types can be used with a swtich statement
A
int, char, String
2
Q
why can’t double be used with a switch statement
A
real numbers are continuous and you can’t guarantee an exact match
3
Q
why shouldn’t you use a boolean in a switch statement?
A
you should use an if statement instead
4
Q
demonstrate using multiple case labels
A
switch (x) {
case 1,2,3
5
Q
A