1.) With switch blocks if you don\'t include a break statement then execution co
ID: 3885447 • Letter: 1
Question
1.)
With switch blocks if you don't include a break statement then execution continues within in the switch block until the next break statement or the end of the block.
True
False
2.)
With a switch statement the structure is set up to compare the variable value or expression in the parentheses of switch(expr) to a case label. If there is a match the code for that case is executed.
True
False
3.)
If an if-statement or loop header has several statements associated with it you must enclose those statements in curly braces.
True
False
4.)
In a switch statement if none of the case labels match the tested variable or expression then the else clause is executed.
True
False
5.)
Assuming you don't use xor how do you test whether one and only one of two variables is zero?
if ($x == 0 and $y != 0 or $y == 0 and $x != 0)
if ($x = 0 or $y = 0)
if ($x == 0 or $y == 0)
if ($x == 0 and $y != 0 and $y == 0 and $x != 0)
6.)
What value of $temp short circuits the $temp <= 100 test in this expression? if ($temp >= 32 and $temp <= 100)
$temp = 0
$temp = 32
$temp = 100
$temp = 75
7.)
Which city is echoed?
$answer = 4;
switch($answer) {
case 1:
echo ""Detroit"";
break;
case 3:
echo ""Chicago"";
break;
case 5:
echo ""Nashville"";
break;
default:
echo ""New York"";
}
New York
Chicago
Detroit
Nashville
if ($x == 0 and $y != 0 or $y == 0 and $x != 0)
if ($x = 0 or $y = 0)
if ($x == 0 or $y == 0)
if ($x == 0 and $y != 0 and $y == 0 and $x != 0)
6.)
What value of $temp short circuits the $temp <= 100 test in this expression? if ($temp >= 32 and $temp <= 100)
$temp = 0
$temp = 32
$temp = 100
$temp = 75
7.)
Which city is echoed?
$answer = 4;
switch($answer) {
case 1:
echo ""Detroit"";
break;
case 3:
echo ""Chicago"";
break;
case 5:
echo ""Nashville"";
break;
default:
echo ""New York"";
}
New York
Chicago
Detroit
Nashville
Explanation / Answer
1.)With switch blocks if you don't include a break statement then execution continues within in the switch block until the next break statement or the end of the block.
Answer: True
2.)With a switch statement the structure is set up to compare the variable value or expression in the parentheses of switch(expr) to a case label. If there is a match the code for that case is executed.
Answer: True
3.)If an if-statement or loop header has several statements associated with it you must enclose those statements in curly braces.
Answer: True
if(condition){
x = y;
data = x;
}
4.)In a switch statement if none of the case labels match the tested variable or expression then the else clause is executed.
Answer : False
why? default get executed
5.)
if ($x == 0 and $y != 0 or $y == 0 and $x != 0)
6) $temp = 0
(0 >= 32 and 0 <= 100) condition fails
7)
Answer : New York
default is selected because nothing match with 4
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.