Question
When would you use a case in a switch statement that does not have a break at the end of it? when you want it
When would you use a case in a switch statement that does not have a break at the end of it?
when you want it to stop at the end of the case | ||
only when it is the default case. | ||
when you want to perform the same action for several cases. | ||
when you want to get it to exit the switch statement |
When is the default case executed?
right after the break in a previous case | ||
when none of the other cases are matched. | ||
only when the wrong type is used with the switch | ||
when all of the other cases are matched |
In a switch, how do you handle a range of values like 2-5:
case 2-5: | ||
case 2:5 : | ||
cases matching 2,3,4 which fall into case 5. | ||
case 2,3,4,5: |
What happens if the switch does not contain a default case and the value for the switch matches none of the cases?
execution continues at the end of the switch statement | ||
it executes the last case | ||
it executes the else for the switch statement | ||
it returns to the top and executes the switch again |
What is the result of (2 > 5) ? 3 : 7
0 | ||
3 | ||
1 | ||
7 |
What happens if a switch statement receives a value that matches more than one case?
it executes all the cases which match. | ||
it execute only the last case which matches. | ||
it executes only the first case which is matched. | ||
it executes the default case. |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started