Font size
Worksheetsswitch case
Total questions: 17
Worksheet time: 9mins
By the ? keyword, the other cases will not be executed and the program continues executing the code after the switch case if there is more code.
Which is the "?" keyword?
(a)
What is the keyword that we use, when we want to have different cases based on the expression's value?
switch
Switch
if
default
Can I make a switch case without inserting code to be executed in the default case?
No
Yes
Can you use if case instead of switch case?
Yes
No
Is that correct?
switch (number < 10) ...
Yes
No
Choose the correct answer
case "cat":
case: cat
case: "cat"
case cat:
Is that correct "case 5:"?
Yes
No
Is that correct?
case "s":
Yes
No
Select the correct option :
The switch expression is evaluated ____________
once
twice
every time the condition is checked
Select the correct option :
The _____ in switch statement is used to terminate the execution of the rest of the code in the switch block.
default
case
break
State True or False :
The default statement is compulsory and it can be used anywhere inside the switch statement.
True
False
State True or False :
It is not necessary to break the last case in a switch block.
True
False
Select the correct option:
Switch case is a __________ statement.
default
loop
break
conditional
Select the correct option:
_______________ is a situation that occurs when we miss out break statement with switch cases.
Fall through
Default
Desired output
No output
Select the correct option :
Switch case uses _______________ to match value and type.
comparison
==
strict comparison
<and>
Select the correct output for following code snippet :
var d=1, e=2,g=3,i=1;
switch(i)
{
case 1 : d=d+1;
case 2 : e=e+1;
case 3 : g=g+1;
}
document.write(d+ " " + e+ " " +g);
2
234
2 3 4
No output
The user is not getting any output. Select the line which has error :
var fruit = "apples" - Line 1
switch(fruit) - Line 2
case "grapes" : - Line 3
document.write("Green or black?"); - Line 4
break; - Line 5
case "apples" : - Line 6
document.write("Red are the best") - Line 7
break; - Line 8
default : - Line 9
document.write("Enter apples or grapes "); - Line 10
} - Line 11
Line 1
Line 3
Line 7
Line 11
