Switch statements Flashcards

1
Q

what 3 data types can be used with a swtich statement

A

int, char, String

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

why shouldn’t you use a boolean in a switch statement?

A

you should use an if statement instead

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

demonstrate using multiple case labels

A

switch (x) {
case 1,2,3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly