1. The rule for lining up, or matching, elses is that the else is matched with t
ID: 3798738 • Letter: 1
Question
1. The rule for lining up, or matching, elses is that the else is matched with the first if, from top to bottom.
True
False
2. if (amount > 1000)
result = 1;
else
if (amount > 500)
result = 2;
else
if (amount > 100)
result = 3;
else
result = 4;
Using the above code segment, what is stored in result when amount is equal to 14?
1
2
3
4
3. Placing a semicolon onto the end of the conditional one-way if statement ____.
causes the expression to evaluate to true
causes the expression to evaluate to false
produces a syntax error
produces a null empty bodied true statement
4. The switch statement is considered a multiple selection structure and it also goes by the name case statement.
True
False
5.
switch (phoneDigit)
{
case 1: num = 1;
break;
case 2: num = 2;
break;
case 3: num = 3;
break;
case 4: num = 4;
break;
default: num = 0;
break;
}
Looking at the example above, what happens if the break is omitted?
num is assigned 1
a syntax error is generated
num is never assigned a value
num is always assigned 0
6.
if (examScore is less than 50)
display message “Do better on next exam”
In the statement above, the entry inside the parentheses is called the ____.
selection construct
statement body
truth value
conditional expression
7. When strings are compared, the first character in the first operand is compared against the first character in the second operand.
True
False
8. The logical operators in C# are ____.
&& and ||
>, <, >=, <=
!= and ==
==, =, and !=
9. When you compare characters stored in char memory locations using relational operators, ____.
you get inconsistent results
you receive an error message
they are always considered equal
they are compared lexicographically
10. Selection statements must include a Boolean variable.
True
False
a.1
b.2
c.3
d.4
Explanation / Answer
1. False, The else is matched with the immediate previous if
2. d. 4 - since every other condition checks for value above a certain value, control will go to the final else.
3. d. prodcues a null bodied empty bodied true statement.
4. true ,
syntax:
switch(choice)
{
case 1: statement 1
case 2: statement 2
}
5. d. num is always assigned 0. This is because when break is ommitted, all the statements gets executed and hence the last statement num = 0 overrides the previous executions.
6. d. conditional expression
7. true
8. a. && and ||
9. d. they are compared lexographically
10. false
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.