True/False Indicate whether the
statement is true or false.
|
|
1.
|
Using a single equal symbol inside a conditional expression, where a test was
intended, causes a syntax error to be issued in C#.
|
|
2.
|
int sum = 0; int number = 0; while (number <
10) { sum = sum +
number; Console.WriteLine(sum); }
The statement above prints the
values of 0 through 9 on separate lines.
|
|
3.
|
Selection statements must include a Boolean variable.
|
|
4.
|
The not equal (!=), and equal (==) symbols are overloaded operators.
|
|
5.
|
C# performs automatic garbage collection once the loop is finished and releases
any variables declared as part of the loop.
|
|
6.
|
The while statement is the only type of loop construct that can be used to
develop a sentinel-controlled loop.
|
|
7.
|
String operands can be compared using the relational symbols. They are compared
lexicographically using their Unicode character representation.
|
|
8.
|
Relational operators allow you to test variables to see if one is greater or
less than another variable or value.
|
|
9.
|
The conditional expression, sometimes called “the test,” must
evaluate to true.
|
|
10.
|
Scope refers to the region in the program in which you can use the
variable.
|
Multiple Choice Identify the
choice that best completes the statement or answers the question.
|
|
11.
|
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, when phoneDigit has a value of ‘Q’, what
value is stored in num?
a. | 1 | c. | Q | b. | 0 | d. | not enough information
given |
|
|
12.
|
A common problem associated with counter-controlled loops is not executing the
loop for the last value. This type of problem is labeled a(n) ____ error.
a. | off-by-one | c. | counter controlled | b. | last-value | d. | boundaries |
|
|
13.
|
How can the compound conditional expression ((average > 79 && average
<= 89)) be written to eliminate the logical operator - without changing the logic?
a. | remove the && and create a nested if statement | c. | by replacing the && with
|| | b. | (average > 79 <= 89) | d. | (79 > average <= 89) |
|
|
14.
|
The only posttest loop structure available in C# is _____.
a. | while | c. | do...while | b. | for | d. | foreach |
|
|
15.
|
To “prime the read” with a loop, you place an input statement
____.
a. | inside the loop body | c. | after the loop body | b. | before the loop body | d. | as part of the loop conditional
expression |
|
|
16.
|
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?
|
|
17.
|
int loopVariable = 0; do {
Console.WriteLine(“Count = {0:}“, ++loopVariable); }while (loopVariable
< 5); How many times will be loop body be executed?
|
|
18.
|
if (aValue < largest ) result =
aValue; else result = largest; What happens
when aValue is equal to largest in the program segment above?
a. | result is assigned aValue | c. | nothing, neither assignment
statement is executed | b. | result is assigned largest | d. | an error is
reported |
|
|
19.
|
The most appropriate sentinel value that might be selected for month of the year
is ____.
|
|
20.
|
A method that calls itself repeatedly until it arrives at the solution is a(n)
____method.
a. | static | c. | iterative | b. | recursive | d. | instance |
|
|
21.
|
Instead of requiring that a dummy value be entered after all values are
processed, a ____-controlled loop initializes a variable on the outside of the loop and then
evaluates the variable to see when it changes values. Its value is changed inside the loop body when
the loop should exit.
a. | counter | c. | state | b. | sentinel | d. | change |
|
|
22.
|
int loopVariable = 0; do {
Console.WriteLine(“Count = {0:}“, ++loopVariable); }while (loopVariable
< 5); What will be printed during the first iteration through the loop?
a. | 0 | c. | 10 | b. | 1 | d. | none of the
above |
|
|
23.
|
if (examScore is less than 50) display message “Do better on next
exam” The result of the expression above is ____.
a. | true or false | c. | numeric | b. | true | d. | 100 |
|
|
24.
|
if (examScore > 89) grade =
‘A’; The expression above is considered a(n) ____.
a. | iteration statement | c. | one-way if statement | b. | two-way if statement | d. | simple sequence
instruction |
|
|
25.
|
int counter = 0; while (counter < 100) {
Console.WriteLine(counter); counter++; } The first value printed
with the program segment above is ____.
|