Wednesday, June 3, 2009

statement

1. Listing cases consecutively with no statements between them enables the cases to perform the same set of statements.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




2. An expression containing operator || is true if either or both of its operands are true.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




3. The default label is required in the switch selection statement.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




4. Assume the integer variables sum and count have been declared. This code sums the odd integers between 1 and 99, inclusive, using a for statement.

sum = 0;
for ( count = 1; count <= 99; count += 2 )
sum += count;

A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




5. The integer after the comma (,) in a format item ( e.g., {0,4} ) indicates the field width of the displayed string.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




6. The expression ( x > y && a < b ) is true if either the expression x > y is true or the expression a < b is true.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




7. To test for a range of values in a switch statement, use a hyphen ( - ) between the start and end values of the range in a case label.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




8. The break statement is required in every case of a switch selection statement to exit the switch properly.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




9. Assume that the variable n has been declared, but not initialized. Which of these match the output of these C# statements?

n = 1;
while ( n < 10 )
Console.Write( n++ );

A) 0123456789
B) 012345678910
C) 123456789
D) 12345678910
E) None of these.

Points Earned: 1.0/1.0
Correct Answer(s): C




10. Match each of these code segments to the appropriate comment.
A. The code segment has valid syntax, but it has some other error.
B. The code segment has valid syntax and no logic errors.
C. Infinite loop.
D. Floating-point number is not allowed here.
E. The code segment has invalid syntax.
F. Missing break statement.


ABCDEF
float y;
for ( y = .1; y != 1.0; y += .1 )
Console.WriteLine( y );
ABCDEF
x = 1;
while (x <= 10);
{
x++;
}
ABCDEF
n = 1;
while ( n < 10 )
Console.WriteLine( n++ );
ABCDEF
int n;
n = 1;
switch ( n )
{
case 1:
Console.WriteLine( "The number is 1." );
case 2:
Console.WriteLine( "The number is 2." );
break;
default:
Console.WriteLine( "The number is not 1 or 2." );
break;
}
Points Earned: 4.0/4.0
Correct Answer(s): Infinite loop. :
x = 1;
while (x <= 10);
{
x++;
}, Floating-point number is not allowed here. :
float y;
for ( y = .1; y != 1.0; y += .1 )
Console.WriteLine( y );, Missing break statement. :
int n;
n = 1;
switch ( n )
{
case 1:
Console.WriteLine( "The number is 1." );
case 2:
Console.WriteLine( "The number is 2." );
break;
default:
Console.WriteLine( "The number is not 1 or 2." );
break;
}, The code segment has valid syntax and no logic errors. :
n = 1;
while ( n < 10 )
Console.WriteLine( n++ );




11. Assume that the variable x has been declared, but not initialized. Select the phrase that describes the effect of each these proposed C# statements or groups of statements.
A. This code prints a newline character if x is evenly divisible by 5. If it is not, a tab character is printed.
B. A statement that prints an integer and advances to a new line.
C. The control statement of a for loop that loops 20 times. The counter variable is x.
D. A statement that prints an integer but does not advance to the next line.
E. The code has invalid syntax.
F. The number 2.5 is raised to the power of 3.
G. The statement has valid syntax, but does none of the above.
H. The control statement of a while loop that loops 20 times. The counter variable is x.
I. The number 3 is raised to the power of 2.5.


ABCDEFGHIConsole.Write( x );
ABCDEFGHI
if ( x % 5 == 0 )
Console.WriteLine();
else
Console.Write('\t');
ABCDEFGHIfor ( x = 1; x <= 20; x++ )
ABCDEFGHIdouble result = math.Pow( 2.5, 3 );
ABCDEFGHIwhile ( x <= 20 )
Points Earned: 4.0/4.0
Correct Answer(s): The control statement of a while loop that loops 20 times. The counter variable is x. : while ( x <= 20 ), The control statement of a for loop that loops 20 times. The counter variable is x. : for ( x = 1; x <= 20; x++ ), The number 2.5 is raised to the power of 3. : double result = math.Pow( 2.5, 3 );, A statement that prints an integer but does not advance to the next line. : Console.Write( x );, This code prints a newline character if x is evenly divisible by 5. If it is not, a tab character is printed. :
if ( x % 5 == 0 )
Console.WriteLine();
else
Console.Write('\t');




12. Select the best word or operator to fill the blank.
A. before
B. dynamic
C. true
D. switch
E. while
F. if
G. for
H. continue
I. break
J. static
K. &&
L. false
M. after
N. ||


ABCDEFGHIJKLMNTypically, ____ statements are used for sentinel-controlled repetition.
ABCDEFGHIJKLMNThe ___ statement, when executed in a repetition statement, skips the remaining statements in the loop body and proceeds with the next iteration of the loop.
ABCDEFGHIJKLMNTypically, ____ statements are used for counter-controlled repetition.
ABCDEFGHIJKLMNIf the loop-continuation condition in a for header is initially ____, the for statement's body does not execute.
ABCDEFGHIJKLMNMethods that perform common tasks and do not need to be called on objects are called ____ methods.
ABCDEFGHIJKLMNThe ____ operator can be used to ensure that two conditions are both true before choosing a certain path of execution.
ABCDEFGHIJKLMNThe ____ statement selects among multiple actions based on the possible values of an integer variable or expression.
ABCDEFGHIJKLMNThe do...while statement tests the loop-continuation condition ____ executing the loop's body.
Points Earned: 7.0/7.0
Correct Answer(s): for : Typically, ____ statements are used for counter-controlled repetition., while : Typically, ____ statements are used for sentinel-controlled repetition., after : The do...while statement tests the loop-continuation condition ____ executing the loop's body., switch : The ____ statement selects among multiple actions based on the possible values of an integer variable or expression., continue : The ___ statement, when executed in a repetition statement, skips the remaining statements in the loop body and proceeds with the next iteration of the loop., && : The ____ operator can be used to ensure that two conditions are both true before choosing a certain path of execution., false : If the loop-continuation condition in a for header is initially ____, the for statement's body does not execute., static : Methods that perform common tasks and do not need to be called on objects are called ____ methods.

phrase of C++

1. Select the phrase that describes the effect of each these proposed C++ statements.
A. Declare variable sum to be of type int.
B. The proposed statement has invalid syntax.
C. The statement has valid syntax, but does none of the above.
D. Print "The sum is: " followed by the value of variable sum.
E. Set variable x to 1.
F. Declare variable x to be of type int.
G. Set variable sum to 0.
H. Add variable x to variable sum and assign the result to variable sum.


ABCDEFGHint x;
ABCDEFGHx = 1;
ABCDEFGH1 = x;
ABCDEFGHint sum;
ABCDEFGH0 = sum;
ABCDEFGHsum int;
ABCDEFGHsum = 0;
ABCDEFGHsum += x;
ABCDEFGHx += x;
ABCDEFGHConsole.WriteLine( "The sum is: {0}", sum );
ABCDEFGHConsole.WriteLine( "The sum is:{0}", sum );
ABCDEFGHx int;
Points Earned: 10.0/12.0
Correct Answer(s): Declare variable sum to be of type int. : int sum;, Declare variable x to be of type int. : int x;, Set variable x to 1. : x = 1;, Set variable sum to 0. : sum = 0;, The statement has valid syntax, but does none of the above. : x += x;, The proposed statement has invalid syntax. : 0 = sum;, Add variable x to variable sum and assign the result to variable sum. : sum += x;, Print "The sum is: " followed by the value of variable sum. : Console.WriteLine( "The sum is: {0}", sum );, The proposed statement has invalid syntax. : sum int;, The proposed statement has invalid syntax. : x int;, The proposed statement has invalid syntax. : 1 = x;, The statement has valid syntax, but does none of the above. : Console.WriteLine( "The sum is:{0}", sum );




2. Select the matching word or phrase.
A. for-next
B. definite
C. loop
D. if-else
E. if-true
F. flag
G. process
H. repetition
I. sequence
J. selection
K. loop-while
L. statement
M. loop-when
N. for-loop
O. if-then


ABCDEFGHIJKLMNOThe ____ selection statement is used to execute one action when a condition is true or a different action when the condition is false.
ABCDEFGHIJKLMNOWhen it is not known in advance how many times a set of statements will be repeated, a(n) ____ value can be used to terminate the repetition.
ABCDEFGHIJKLMNORepeating a set of instructions a specific number of times is called ____ repetition.
ABCDEFGHIJKLMNOAll programs can be written in terms of three types of control structures: loop, decision and ____.
Points Earned: 4.0/4.0
Correct Answer(s): sequence : All programs can be written in terms of three types of control structures: loop, decision and ____., definite : Repeating a set of instructions a specific number of times is called ____ repetition., flag : When it is not known in advance how many times a set of statements will be repeated, a(n) ____ value can be used to terminate the repetition., if-else : The ____ selection statement is used to execute one action when a condition is true or a different action when the condition is false.




3. Select the phrase that describes the effect of each these proposed C++ statements.
A. If count is greater than 10, print "Count is greater than 10."
B. Calculate the remainder after q is divided by divisor and assign the result to q.
C. Assign the sum of x and y to z and then add 1 to x.
D. The statement has valid syntax, but does none of the above.
E. Add 1 to x and then assign the sum of x and y to z.
F. Predecrement the variable x and then subtract it from total.
G. The proposed statement has invalid syntax.


ABCDEFGq = q % divisor;
ABCDEFGx++ + y = z;
ABCDEFGz = x++ + y;
ABCDEFGif ( count > 10 ) Console.WriteLine( "Count is greater than 10." );
ABCDEFGtotal = --x;
ABCDEFGtotal -= --x;
ABCDEFGtotal = total - x;
ABCDEFGz = ++x + y;
ABCDEFGq %= divisor;
Points Earned: 9.0/9.0
Correct Answer(s): Assign the sum of x and y to z and then add 1 to x. : z = x++ + y;, The proposed statement has invalid syntax. : x++ + y = z;, Add 1 to x and then assign the sum of x and y to z. : z = ++x + y;, If count is greater than 10, print "Count is greater than 10." : if ( count > 10 ) Console.WriteLine( "Count is greater than 10." );, Predecrement the variable x and then subtract it from total. : total -= --x;, The statement has valid syntax, but does none of the above. : total = total - x;, The statement has valid syntax, but does none of the above. : total = --x;, Calculate the remainder after q is divided by divisor and assign the result to q. : q %= divisor;, Calculate the remainder after q is divided by divisor and assign the result to q. : q = q % divisor;




4. Consider each statement separately and independently. For each, assume that a has a value of 120 and x has a value of 5 before the statement is executed. What will the variables' values be after they execute?
A. a = 20, x = 6
B. a = 480, x = 4
C. a = 480, x = 5
D. a = 24, x = 4
E. a = 720, x = 6
F. The statement has invalid syntax.
G. a = 24, x = 5
H. a = 20, x = 4
I. a = 24, x = 6
J. a = 600, x = 5
K. a = 480, x = 6
L. a = 30, x = 6
M. a = 720, x = 4
N. a = 720, x = 5
O. a = 30, x = 4
P. The statement has valid syntax, but none of the above is correct. The statement has valid syntax, but none of the above is correct.
Q. a = 20, x = 5
R. a = 30, x = 5
S. a = 600, x = 4
T. a = 600, x = 6


ABCDEFGHIJKLMNOPQRSTa /= --x;
ABCDEFGHIJKLMNOPQRSTa /= x--;
ABCDEFGHIJKLMNOPQRSTa *= ++x;
ABCDEFGHIJKLMNOPQRSTa *= x;
ABCDEFGHIJKLMNOPQRSTa /= x;
ABCDEFGHIJKLMNOPQRSTa *= x++;
Points Earned: 6.0/6.0
Correct Answer(s): a = 600, x = 6 : a *= x++;, a = 24, x = 4 : a /= x--;, a = 720, x = 6 : a *= ++x;, a = 30, x = 4 : a /= --x;, a = 600, x = 5 : a *= x;, a = 24, x = 5 : a /= x;




5. Select the phrase that describes the effect of each these proposed C++ statements.
A. The statement has valid syntax, but does none of the above.
B. Multiply a and b, putting the result in c.
C. Multiply c by 5, putting the result in c.
D. Add a and b, putting the result in c.
E. Add 1 to c, putting the result in c.
F. Multiply b by a, putting the result in b.
G. The proposed statement has invalid syntax.
H. Add a to b, putting the result in b.


ABCDEFGH++c;
ABCDEFGHc = c * 5;
ABCDEFGHc += 1;
ABCDEFGHc = a * b;
ABCDEFGHc *= 5;
ABCDEFGHc = a + b
ABCDEFGH**c;
ABCDEFGHc = b + a;
ABCDEFGHb *= a;
ABCDEFGHc = c + 1;
ABCDEFGHc**;
ABCDEFGHc = b * a
ABCDEFGHc++;
ABCDEFGHb += a;
Points Earned: 13.0/14.0
Correct Answer(s): Add 1 to c, putting the result in c. : c += 1;, Add 1 to c, putting the result in c. : ++c;, Add 1 to c, putting the result in c. : c++;, Multiply c by 5, putting the result in c. : c = c * 5;, Multiply a and b, putting the result in c. : c = a * b;, The proposed statement has invalid syntax. : c = b * a, Multiply b by a, putting the result in b. : b *= a;, Multiply c by 5, putting the result in c. : c *= 5;, The proposed statement has invalid syntax. : **c;, The proposed statement has invalid syntax. : c**;, Add 1 to c, putting the result in c. : c = c + 1;, The proposed statement has invalid syntax. : c = a + b, Add a and b, putting the result in c. : c = b + a;, Add a to b, putting the result in b. : b += a;

More Methods

1. Select the best matching word or term.
A. class
B. single-precision
C. property
D. int
E. global
F. new
G. type
H. ToInt32
I. instance
J. ToDecimal
K. method
L. float
M. double-precision


ABCDEFGHIJKLMVariables of type double represent ____ floating-point numbers.
ABCDEFGHIJKLMOperator ____ creates an object of the class specified to the right of the keyword.
ABCDEFGHIJKLMC# provides three simple types for storing real numbers -- double, decimal and ____.
ABCDEFGHIJKLMBy default, classes that are not explicitly declared in a namespace are implicitly placed in the ____ namespace.
ABCDEFGHIJKLMConvert method ____ returns a decimal value.
ABCDEFGHIJKLMEach parameter must specify both a name and a(n) ____.
ABCDEFGHIJKLMEvery class declaration contains keyword ____ followed immediately by the class's name.
ABCDEFGHIJKLMWhen each object of a class maintains its own copy of an attribute, the field that represents the attribute is also known as a(n) ____ variable.
ABCDEFGHIJKLMA house is to a blueprint as a(n) ____ is to a class.
Points Earned: 9.0/9.0
Correct Answer(s): ToDecimal : Convert method ____ returns a decimal value., double-precision : Variables of type double represent ____ floating-point numbers., float : C# provides three simple types for storing real numbers -- double, decimal and ____., instance : When each object of a class maintains its own copy of an attribute, the field that represents the attribute is also known as a(n) ____ variable., global : By default, classes that are not explicitly declared in a namespace are implicitly placed in the ____ namespace., type : Each parameter must specify both a name and a(n) ____., new : Operator ____ creates an object of the class specified to the right of the keyword., class : Every class declaration contains keyword ____ followed immediately by the class's name., instance : A house is to a blueprint as a(n) ____ is to a class.




2. Select the best matching word or term.
A. single-precision
B. reference
C. access modifier
D. utility specifier
E. double-precision
F. primitive
G. $
H. auto-generated accessors
I. void
J. ReadInput
K. real
L. C
M. ReadLine
N. using statement
O. auto-implemented property
P. using directive
Q. value


ABCDEFGHIJKLMNOPQVariables of type float represent ____ floating-point numbers.
ABCDEFGHIJKLMNOPQFor a(n) ____, the compiler automatically generates a private instance variable and set and get accessors.
ABCDEFGHIJKLMNOPQKeyword public is a(n) ____.
ABCDEFGHIJKLMNOPQTypes are value types or ____ types.
ABCDEFGHIJKLMNOPQA(n) ____ is not required if you always refer to a class with its fully qualified class name.
ABCDEFGHIJKLMNOPQThe format specifier ____ is used to display values in a monetary format.
ABCDEFGHIJKLMNOPQReturn type ____ indicates that a method will not return any information when it completes its task.
ABCDEFGHIJKLMNOPQConsole method ____ reads characters until a newline character is encountered.
Points Earned: 7.0/8.0
Correct Answer(s): auto-implemented property : For a(n) ____, the compiler automatically generates a private instance variable and set and get accessors., reference : Types are value types or ____ types., C : The format specifier ____ is used to display values in a monetary format., single-precision : Variables of type float represent ____ floating-point numbers., using directive : A(n) ____ is not required if you always refer to a class with its fully qualified class name., ReadLine : Console method ____ reads characters until a newline character is encountered., void : Return type ____ indicates that a method will not return any information when it completes its task., access modifier : Keyword public is a(n) ____.




3. The body of any method or property is delimited by left and right braces.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




4. An instance variable is declared in a class, but not in the body of any of the class's methods.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




5. Local variables are initialized by default.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




6. An argument is the actual value that is passed to a method parameter when a method is called.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




7. By convention, method names begin with a lowercase first letter and all subsequent words in the name begin with a capital first letter.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




8. A property's get accessor enables a client to modify the value of the instance variable associated with the property.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




9. Each parameter required by a method is specified in the method's declaration.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




10. Variables declared in the body of a particular method are known as instance variables and can be used in all methods of the class.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




11. Variables or methods declared with access modifier private are accessible only to methods and properties of the class in which they are declared.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




12. The number of arguments in the method call must match the number of parameters in the method declaration's parameter list.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




13. Any class that contains public static void Main( string[] args ) can be used to execute an application.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




14. Empty parentheses following a method name in a method declaration indicate that the method does not require any parameters to perform its task.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




15. In general, instance variables are accessible to all methods of the class.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




16. Every instance of a class has a separate copy of the class's instance variables.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




17. Reference-type instance variables are initialized by default to the value null.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




18. A property declaration must contain both a get accessor and a set accessor.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




19. After defining a property, you can use it the same way you use a method, but with empty parentheses, because no arguments are passed to a property.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




20. Real number values that appear in source code are known as floating-point literals and are of type float by default.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




21. A using directive is not required when one class in a namespace uses another in the same namespace.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True

C# applications

1. Select the matching word, phrase or acronym for each question.
A. colon
B. Main
C. blank lines
D. if
E. newline
F. Console.Write
G. keywords
H. brace
I. EOF
J. //
K. start
L. comma
M. STX
N. semicolon


ABCDEFGHIJKLMNMost C# statements end with a(n) ____.
ABCDEFGHIJKLMN____ are reserved for use by C#.
ABCDEFGHIJKLMNA left ____ begins the body of every method and a right ____ ends the body of every method.
ABCDEFGHIJKLMNNewline, space and tab characters and ____ are called whitespace characters.
ABCDEFGHIJKLMNMethods WriteLine and ____ display information in the console window.
ABCDEFGHIJKLMNThe escape sequence \n represents the ____ character, which causes the cursor to position to the beginning of the next line on the screen.
ABCDEFGHIJKLMN____ begins a single-line comment.
ABCDEFGHIJKLMNThe ____ statement is used to make decisions.
ABCDEFGHIJKLMNC# applications begin execution at method ____.
Points Earned: 8.0/8.0
Correct Answer(s): brace : A left ____ begins the body of every method and a right ____ ends the body of every method., semicolon : Most C# statements end with a(n) ____., newline : The escape sequence \n represents the ____ character, which causes the cursor to position to the beginning of the next line on the screen., if : The ____ statement is used to make decisions., // : ____ begins a single-line comment., blank lines : Newline, space and tab characters and ____ are called whitespace characters., keywords : ____ are reserved for use by C#., Main : C# applications begin execution at method ____., Console.Write : Methods WriteLine and ____ display information in the console window.




2. Match the correct C# statements to each programming task.
A. Console.Write( "Enter an integer: " );
B. Console.WriteLine( "{0}\n{1}", "This is a Visual C++", "program" );
C. int c, thisIsAVariable, q76354, number;
D. if ( number != 7 ) Console.WriteLine( "The variable number is not equal to 7" );
E. age = Convert.ToInt32(Console.ReadLine() );
F. Console.WriteLine( "This\tis\ta\tVisual\tC++\tprogram\n" );
G. Console.WriteLine( "This is a Visual C++ program\n" );
H. Console.WriteLine( "This\nis\na\nVisual\nC++\nprogram\n" );
I. Console.WriteLine( "This is a Visual C++\nprogram\n" );


ABCDEFGHIInput an integer from the user at the keyboard and store it in integer variable age.
ABCDEFGHIPrompt the user to enter an integer.
ABCDEFGHIDeclare the variables c, thisIsAVariable, q76354 and number to be of type int.
ABCDEFGHIPrint the message "This is a Visual C++ program". Separate each word from the next by a tab.
ABCDEFGHIPrint the message "This is a Visual C++ program" on two lines using a single statement and a single string. End the first line with C++.
ABCDEFGHIPrint the message "This is a Visual C++ program" with each word on a separate line.
ABCDEFGHIPrint the message "This is a Visual C++ program" on one line.
ABCDEFGHIIf the variable number is not equal to 7, print "The variable number is not equal to 7".
ABCDEFGHIPrint the message "This is a Visual C++ program" on two lines using a single statement and two format items. End the first line with C++.
Points Earned: 8.0/8.0
Correct Answer(s): int c, thisIsAVariable, q76354, number; : Declare the variables c, thisIsAVariable, q76354 and number to be of type int., Console.Write( "Enter an integer: " ); : Prompt the user to enter an integer., age = Convert.ToInt32(Console.ReadLine() ); : Input an integer from the user at the keyboard and store it in integer variable age., if ( number != 7 ) Console.WriteLine( "The variable number is not equal to 7" ); : If the variable number is not equal to 7, print "The variable number is not equal to 7"., Console.WriteLine( "This is a Visual C++\nprogram\n" ); : Print the message "This is a Visual C++ program" on two lines using a single statement and a single string. End the first line with C++., Console.WriteLine( "{0}\n{1}", "This is a Visual C++", "program" ); : Print the message "This is a Visual C++ program" on two lines using a single statement and two format items. End the first line with C++., Console.WriteLine( "This\tis\ta\tVisual\tC++\tprogram\n" ); : Print the message "This is a Visual C++ program". Separate each word from the next by a tab., Console.WriteLine( "This is a Visual C++ program\n" ); : Print the message "This is a Visual C++ program" on one line., Console.WriteLine( "This\nis\na\nVisual\nC++\nprogram\n" ); : Print the message "This is a Visual C++ program" with each word on a separate line.




3. Assume the using std::cout; statement appears at the beginning of your program. Which of these statements are true and which are false?
A. True
B. False
C. Not able to say


ABCComments cause the computer to print the text after the // on the screen when the application is executed.
ABCC# considers the variables Number and NuMbEr to be identical.
ABCThe remainder operator (%) can be used only with integer operands.
ABCThe escape sequence \n, when output with cout and the stream insertion operator, causes the cursor to position to the beginning of the next line on the screen.
ABCAll variables must be declared before they are used.
ABCAll variables must be given a type when they are declared.
ABCThe arithmetic operators *, /, %, + and - all have the same level of precedence.
Points Earned: 6.0/6.0
Correct Answer(s): False : Comments cause the computer to print the text after the // on the screen when the application is executed., False : C# considers the variables Number and NuMbEr to be identical., False : The remainder operator (%) can be used only with integer operands., True : The escape sequence \n, when output with cout and the stream insertion operator, causes the cursor to position to the beginning of the next line on the screen., True : All variables must be declared before they are used., True : All variables must be given a type when they are declared., False : The arithmetic operators *, /, %, + and - all have the same level of precedence.




4. Match the correct C# statement (or comment) to each programming task.
A. int x; int y; int z; int result;
B. Console.OutLine( "Enter the first integer: " );
C. z = Convert.ToInt32(Console.ReadLine() );
D. y = Console.ReadLine();
E. // Calculate the product of three integers.
F. Console.WriteLine( "Enter the first integer: " );
G. Console.WriteLine( "Enter the second integer: " );
H. Console.WriteLine( "The product is {0}", result );
I. Console.OutLine( "Enter the third integer: " );
J. result = x # y # z;
K. y = Convert.ToInt32(Console.ReadLine() );
L. z = Console.ReadLine();
M. Console.WriteLine( "cin >> x >> y >> z" );
N. result = x * y * z;
O. x = Console.ReadLine();
P. Console.WriteLine( "Enter the third integer: " );
Q. int x, int y, int z, int result;
R. x = Convert.ToInt32(Console.ReadLine() );
S. Console.OutLine( "Enter the second integer: " );
T. Console.WriteLine( "The product is result" );
U. *** Calculate the product of three integers. ***


ABCDEFGHIJKLMNOPQRSTUPrompt the user to enter the third integer. Leave the cursor at the end of the line.
ABCDEFGHIJKLMNOPQRSTURead an integer from the keyboard and store it in the variable z.
ABCDEFGHIJKLMNOPQRSTURead an integer from the keyboard and store it in the variable y.
ABCDEFGHIJKLMNOPQRSTUPrint "The product is " followed by the value of the variable result.
ABCDEFGHIJKLMNOPQRSTUPrompt the user to enter the second integer. Leave the cursor at the end of the line.
ABCDEFGHIJKLMNOPQRSTUState that a program calculates the product of three integers.
ABCDEFGHIJKLMNOPQRSTUDeclare the variables x, y, z and result to be of type int (in separate statements).
ABCDEFGHIJKLMNOPQRSTUCompute the product of the three integers contained in variables x, y and z, and assign the result to the variable result.
ABCDEFGHIJKLMNOPQRSTURead an integer from the keyboard and store it in the variable x.
ABCDEFGHIJKLMNOPQRSTUPrompt the user to enter the first integer. Leave the cursor at the end of the line.
Points Earned: 9.0/10.0
Correct Answer(s): // Calculate the product of three integers. : State that a program calculates the product of three integers., int x; int y; int z; int result; : Declare the variables x, y, z and result to be of type int (in separate statements)., Console.WriteLine( "Enter the first integer: " ); : Prompt the user to enter the first integer. Leave the cursor at the end of the line., x = Convert.ToInt32(Console.ReadLine() ); : Read an integer from the keyboard and store it in the variable x., Console.WriteLine( "Enter the second integer: " ); : Prompt the user to enter the second integer. Leave the cursor at the end of the line., y = Convert.ToInt32(Console.ReadLine() ); : Read an integer from the keyboard and store it in the variable y., Console.WriteLine( "Enter the third integer: " ); : Prompt the user to enter the third integer. Leave the cursor at the end of the line., z = Convert.ToInt32(Console.ReadLine() ); : Read an integer from the keyboard and store it in the variable z., result = x * y * z; : Compute the product of the three integers contained in variables x, y and z, and assign the result to the variable result., Console.WriteLine( "The product is {0}", result ); : Print "The product is " followed by the value of the variable result.

C# Express

1. Select the correct matching term or phrase.
A. visual programming
B. auto-hide
C. expand
D. Project Explorer
E. numerically
F. Solution Explorer
G. project
H. mini toolbar
I. categorically
J. solution
K. tool tip
L. add
M. graphical programming


ABCDEFGHIJKLMA(n) ____ is a group of one or more projects that collectively form a Visual C# program.
ABCDEFGHIJKLMA(n) ____ appears when the mouse pointer hovers over an icon.
ABCDEFGHIJKLMA plus box indicates that the tree in the Solution Explorer can ____.
ABCDEFGHIJKLMThe ___ feature hides a window when the mouse pointer is moved outside the window's area.
ABCDEFGHIJKLMThe ___ window allows you to browse solution files.
ABCDEFGHIJKLMThe technique of ____ allows you to create GUIs without writing any code.
ABCDEFGHIJKLMThe properties in the Properties window can be sorted alphabetically or ____.
Points Earned: 7.0/7.0
Correct Answer(s): visual programming : The technique of ____ allows you to create GUIs without writing any code., solution : A(n) ____ is a group of one or more projects that collectively form a Visual C# program., auto-hide : The ___ feature hides a window when the mouse pointer is moved outside the window's area. , tool tip : A(n) ____ appears when the mouse pointer hovers over an icon., Solution Explorer : The ___ window allows you to browse solution files., expand : A plus box indicates that the tree in the Solution Explorer can ____., categorically : The properties in the Properties window can be sorted alphabetically or ____.




2. PictureBoxes typically display images.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




3. Both Forms and Labels have a title bar.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




4. Control properties can be modified only by writing code.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




5. The "X" box toggles auto-hide.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




6. The toolbar icons represent various menu commands.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




7. The toolbar contains icons that represent controls.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




8. A Form's background color is set using the BackColor property.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




9. The IDE's title bar displays the IDE's mode.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




10. Visual C# files use the file extension .csharp.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




11. Select the word or phrase to complete each item.
A. graphical user interface
B. Insert icon
C. File > Save All
D. instant assistance
E. Toolbox
F. Dynamic Help
G. graphical universal interface
H. TextAlign
I. context-sensitive help
J. Text
K. Title
L. Alignment
M. File > Save Solution


ABCDEFGHIJKLMA Form's ____ property specifies the text displayed in the Form's title bar.
ABCDEFGHIJKLMTo save every file in a solution, select ____.
ABCDEFGHIJKLMGUI is an acronym for ____.
ABCDEFGHIJKLMUsing ____ immediately displays a relevant help article.
ABCDEFGHIJKLMUsing ____ displays a list of relevant help articles, based on the current context.
ABCDEFGHIJKLMThe ____ property specifies how text is aligned within a Label's boundaries.
ABCDEFGHIJKLM____ can be accessed using the F1 key.
ABCDEFGHIJKLMThe ____ allows you to add controls to the Form in a visual manner.
Points Earned: 7.0/7.0
Correct Answer(s): Text : A Form's ____ property specifies the text displayed in the Form's title bar., Toolbox : The ____ allows you to add controls to the Form in a visual manner., Dynamic Help : Using ____ displays a list of relevant help articles, based on the current context., TextAlign : The ____ property specifies how text is aligned within a Label's boundaries., File > Save All : To save every file in a solution, select ____., context-sensitive help : Using ____ immediately displays a relevant help article., context-sensitive help : ____ can be accessed using the F1 key., graphical user interface : GUI is an acronym for ____.

Introduction to C #

1. Select the matching word or acronym.
A. XML
B. UNIX
C. assembly
D. programs
E. compilers
F. machine
G. SOAP
H. IDE


ABCDEFGHThe three types of computer languages discussed in the textbook are high-level languages, machine languages and ____ languages.
ABCDEFGHComputers can directly understand only their native ___ language, which is composed only of 1s and 0s.
ABCDEFGHC is widely known as the development language of the ____ operating system.
ABCDEFGHWeb service use ____ to markup information for transmission over the Internet.
ABCDEFGHPrograms that translate high-level-language programs into machine language are called _____.
ABCDEFGHWeb services use ____ to send information over the Internet.
ABCDEFGHVisual Studio is a(n) ______ in which C# programs are developed.
ABCDEFGHComputers process data under the control of sets of instructions called computer _______.
Points Earned: 7.0/7.0
Correct Answer(s): machine : Computers can directly understand only their native ___ language, which is composed only of 1s and 0s. , programs : Computers process data under the control of sets of instructions called computer _______., assembly : The three types of computer languages discussed in the textbook are high-level languages, machine languages and ____ languages., compilers : Programs that translate high-level-language programs into machine language are called _____. , IDE : Visual Studio is a(n) ______ in which C# programs are developed. , UNIX : C is widely known as the development language of the ____ operating system. , XML : Web service use ____ to markup information for transmission over the Internet. , SOAP : Web services use ____ to send information over the Internet.




2. Procedural programming models the world more naturally than object-oriented programming.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




3. MSIL is the common intermediate format to which all .NET programs compile, regardless of their original .NET language.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




4. C# is an object-oriented languageA) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




5. C# is the only language available for programming .NET applications.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




6. The UML is used primarily to implement object-oriented systems.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




7. The .NET Framework is portable to non-Windows platforms.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




8. Computers can directly understand high-level languages.
A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




9. Identify each item as hardware or software.
A. hardware
B. software
C. combination


ABCInput Unit
ABCWord processing program
ABCCPU
ABCKeyboard
ABCA C# program
ABCcompiler
Points Earned: 5.0/5.0
Correct Answer(s): hardware : CPU, software : compiler, hardware : Keyboard, hardware : Input Unit, software : Word processing program, software : A C# program




10. A compiler translates high-level language programs into target-language programs.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




11. High-level languages are generally machine dependent.
A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




12. A machine-language program requires translation before it can be run on a computer.
A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




13. An assembler translates source-language programs into machine-language programs.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




14. The Visual C# compiler translates high-level-language programs into SMIL.
A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




15. A compiler convets source-language programs into target-language programs.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




16. Select the word that correctly expands each acronyms.
A. Consortium
B. Programming
C. Protocol
D. Intermediate
E. Markup
F. Infrastructure
G. Integrated
H. Common
I. Modeling
J. Management


ABCDEFGHIJOMG: Object ____ Group
ABCDEFGHIJCLI: Common Language _____
ABCDEFGHIJIDE: ____ Development Environment
ABCDEFGHIJSOAP: Simple Object Access _____
ABCDEFGHIJXML: Extensible _____ Language
ABCDEFGHIJCLR: ____ Language Runtime
ABCDEFGHIJW3C; World Wide Web ____
ABCDEFGHIJMSIL: Microsoft ____ Language
ABCDEFGHIJUML: Unified ____ Language
ABCDEFGHIJOOP: Object Oriented _____
Points Earned: 9.0/9.0
Correct Answer(s): Consortium : W3C; World Wide Web ____, Markup : XML: Extensible _____ Language, Protocol : SOAP: Simple Object Access _____, Programming : OOP: Object Oriented _____, Common : CLR: ____ Language Runtime, Infrastructure : CLI: Common Language _____, Intermediate : MSIL: Microsoft ____ Language, Modeling : UML: Unified ____ Language, Management : OMG: Object ____ Group, Integrated : IDE: ____ Development Environment

Methods

1. _________ methods can be called without the need for an object of the class to exist.
A) dependent
B) independent
C) special
D) static

Points Earned: 1.0/1.0
Correct Answer(s): D




2. Methods that call themselves are known as ________.
A) reiterative
B) repeat-calling
C) recursive
D) self-calling

Points Earned: 1.0/1.0
Correct Answer(s): C




3. Information may be ____ methods.
A) passed to
B) returned from
C) manipulated in
D) All of the above.

Points Earned: 1.0/1.0
Correct Answer(s): D




4. A method is invoked by a ____.
A) return statement
B) method header
C) method call
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): C




5. A return type of ____ is specified for a method that does not return a value.
A) nothing
B) null
C) void
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): C




6. Methods are called by writing the name of the method followed by ____ enclosed in parentheses.
A) a condition
B) arguments
C) a counter
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): B




7. Which of the following is not a way of packaging code?
A) namespaces
B) variables
C) methods
D) classes

Points Earned: 1.0/1.0
Correct Answer(s): B




8. Programmers write ____ to define specific tasks that may be used at many points in a program.
A) classes
B) methods
C) modules
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): B




9. Many prepackaged classes and methods are provided in the .NET FCL, an acronym for the .
A) Framework Class Library
B) Framework Class Listing
C) Form Class Library
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): A




10. Which of the following correctly calls the Math class method Sqrt with a value of 36?
A) Sqrt(36);
B) Math.Sqrt(36);
C) Math.Sqrt = 36;
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): B




11. Which of the following describes a static variable?
A) a variable with one copy shared by all class objects
B) a variable whose value may not be changed
C) all of the above
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): A




12. When may an application omit the string[] args parameter from the Main header?
A) when the application does not need to use strings
B) when the application does not take command-line arguments
C) when the application does not output any strings
D) All of the above

Points Earned: 1.0/1.0
Correct Answer(s): B




13. Which of the following can be an argument to a method?
A) constants
B) variables
C) expressions
D) All of the above

Points Earned: 1.0/1.0
Correct Answer(s): D




14. How are various parameters separated in the method header?
A) braces
B) brackets
C) periods
D) commas

Points Earned: 1.0/1.0
Correct Answer(s): D




15. Let there be method called Function which takes 3 parameters of type bool. Which of the following method headers could it represent?
A) Function(bool a, bool b, bool c)
B) Function()
C) Both of the above
D) None of the above

Points Earned: 1.0/1.0
Correct Answer(s): A




16. The parameter list in the method header and the arguments in the method call must agree in:
A) number
B) type
C) order
D) all of the above

Points Earned: 1.0/1.0
Correct Answer(s): D




17. When an object is concatenated with a String:
A) a compilation error occurs
B) the object's class name is used
C) the object's ToString method is implicitly called
D) a runtime error occurs

Points Earned: 1.0/1.0
Correct Answer(s): C




18. To call a static method, use the _________ name followed by a period, and the method with its arguments.
A) class's
B) instance variable's
C) namespace's
D) All of the above

Points Earned: 1.0/1.0
Correct Answer(s): A




19. Which keyword can programmers use to break out of a void method?
A) continue
B) next
C) break
D) return

Points Earned: 1.0/1.0
Correct Answer(s): D




20. A static method can ________.
A) call only other static methods of the same class directly
B) manipulate only static fields in the same class directly
C) be called using the class name and a dot (.)
D) All of the above

Points Earned: 1.0/1.0
Correct Answer(s): D




21. Which statement is false?
A) Forgetting to return a value from a method that should return a value is a compilation error.
B) If a method does not return a value, the return-value-type in the method declaration can be omitted.
C) Placing a semicolon after the right parenthesis enclosing the parameter list of a method declaration is a syntax error.
D) Re-declaring a method parameter as a local variable in the method's body is a compilation error.

Points Earned: 1.0/1.0
Correct Answer(s): B




22. Stacks are _____________ data structures.
A) FIFO
B) Random
C) LIFO
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): C




23. What is pushed onto the program execution stack when a method is call?
A) the whole method
B) the return address of the method being called
C) the object of method being called
D) the class of the method being called

Points Earned: 1.0/1.0
Correct Answer(s): B




24. The local variables used in each invocation of a method during an application's execution are stored ________.
A) the program execution stack
B) the activation record
C) the stack frame
D) All of the above.

Points Earned: 1.0/1.0
Correct Answer(s): D




25. A(n) ____ conversion occurs when a type is converted to a type that can hold more data.
A) implicit
B) widening
C) explicit
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): A




26. An int must be explicitly casted to which of the following?
A) sbyte
B) double
C) bool
D) float

Points Earned: 1.0/1.0
Correct Answer(s): A




27. Let x be a double. How can you typecast a double into a float?
A) implicitly
B) x = float
C) (float)x
D) x(float)

Points Earned: 1.0/1.0
Correct Answer(s): C




28. What does the Framework Class Library hold?
A) namespaces
B) classes
C) methods
D) All of the above.

Points Earned: 1.0/1.0
Correct Answer(s): D




29. Which directive allows programmers to use the Framework Class Library?
A) namespace
B) using
C) load
D) import

Points Earned: 1.0/1.0
Correct Answer(s): B




30. A ____ is provided to a random number generator to ensure the same sequence of numbers is not generated during each execution.
A) date
B) parameter
C) seed
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): C




31. Random-number generator scaling is the process of:
A) causing each number in a range to have equal likelihood of being generated
B) modifying the range from which a number will be generated
C) calculating a sequence of numbers to be generated
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): B




32. A(n) ____ is a value type that contains a set of constant values.
A) enumeration
B) object
C) set
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): A




33. Which of the following cannot be an enum's underlying type?
A) int
B) ulong
C) sbyte
D) double

Points Earned: 1.0/1.0
Correct Answer(s): D




34. Identifiers declared within a class have ____.
A) block scope
B) class scope
C) local scope
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): B




35. If a local variable in a method has the same name as a variable in the main program, what will occur?
A) an error is generated
B) the variable in the main program is "hidden" until the method is finished executing
C) the variable in the main program will override the variable from the method
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): B




36. Which of the following statements describes block scope?
A) It begins at the opening { of the class declaration and terminates at the closing }
B) It is valid for one statement only.
C) It limits label scope to only the method in which it is declared.
D) It begins at the identifier's declaration and ends at the terminating right brace (}).

Points Earned: 1.0/1.0
Correct Answer(s): D




37. Which of these statements best defines scope?
A) Scoping allows the programmer to use a class without using its fully qualified name.
B) Scope is the portion of a program that can refer to an entity by its simple name.
C) Scope refers to the classes that have access to a variable.
D) Scope determines whether a variable's value can be altered.

Points Earned: 1.0/1.0
Correct Answer(s): B




38. Which of the following will violate the rules of overloading methods?
A) Methods with the same signatures but different return types.
B) Methods with different number of arguments.
C) Methods with different signatures but the same return type.
D) Method with different types of arguments.

Points Earned: 1.0/1.0
Correct Answer(s): A




39. Which of the following method header represents Function(true, 0, 2.6)?
A) void Function( bool b, double d, int c )
B) void Function( bool b, double d, double d )
C) void Function( bool b, int c, double d )
D) b and c

Points Earned: 1.0/1.0
Correct Answer(s): D




40. Overloaded methods always have the same _________.
A) return type
B) order of the parameter
C) number of the parameters
D) method name

Points Earned: 1.0/1.0
Correct Answer(s): D




41. The technique of dividing large programs into simple problems is known as divide and conquer.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




42. C# provides features to facilitate the design, implementation, operation and maintenance of large programs.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




43. Methods can return at most one value.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




44. The return type of a method's return value is specified in the method call.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




45. Modularizing a program with methods allows software reusability.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




46. Methods should be large and perform as many tasks as possible.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




47. Repeating high-quality, high-performance code in a program helps ensure higher quality programs.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




48. The statements defining a method are written every time they need to be executed.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




49. Prepackaged methods and classes are available for use in the .NET Framework Class Library.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




50. To provide a better understanding of a program, all methods and classes should be written by the programmer.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




51. Methods defined by the programmer may only consist of predefined .NET method calls.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




52. Any variable declared with keyword const is a constant and cannot be changed after the constant is declared.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




53. A static variable represents class-wide information.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




54. A program contains a copy of a static variable for each object that is instantiated.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




55. The Math class only provides methods.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




56. Main is declared static because it is application's entry point; allows the execution environment to invoke Main without creating an instance of the class.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




57. Methods are called by writing the name of the method followed by a left square bracket followed by the argument (or a comma-separated list of arguments) of the method followed by a right square bracket.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




58. Strings can only be concatenated with the function instance_variable.Concat("example").A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




59. When a method call is within another method call, the calls will execute from the outside in.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




60. Method arguments may not be expressions.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




61. A static method may access static and non-static members.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




62. To access the class's non-static members, a static method must use a reference to an object of the class.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




63. When a return statement executes, control proceeds immediately to the first statement after the method that issues the return.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




64. Stack data structures have 3 functions.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




65. Since memory in a computer is finite, an error may occur known as stack overflow.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




66. Conversions that cause data loss are not allowed in C#.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




67. C# will attempt to perform conversions that do not result in data loss implicitly.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




68. Converting a simple type to another simple type may change the value.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




69. By including using System; at the top of a C# source code, programmers can use the unqualified class name, Console, instead of the fully qualified class name, System.Console.A) True
B) False

Points Earned: 0.0/1.0
Correct Answer(s): True




70. Programmers must already know the namespaces he/she needs in order to use the Framework Class Library.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




71. It is always better to write your own code than to search and use a class from the FCL.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




72. Values returned by the Random class method Next are pseudo-random numbers.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




73. The Next method produces a random number from zero up to and including the number it is provided by the programmer.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




74. A particular seed value always produces the same series of random numbers.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




75. When using Next, the range of possible values can be reduced, but the lowest value must be zero.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




76. The values produced by Random are weighted so that some values will be generated with greater frequency than others.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




77. Values produced by random-number generating methods are truly random. There is no way to predict the next result.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




78. If a change is made to an enumeration, the programmer must change the program in every place that the old value was used.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




79. To compare a simple-type value to the underlying value of an enumeration constant, you must use a cast operator to make the two types match.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




80. Any variables declared in a for structure header have block scope within that structure.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True

Arrays

. Which of the following statements about creating arrays and initializing their elements is not true?
A) The elements of an array of integers have a value of null before they are initialized.
B) A for loop is an excellent way to initialize the elements of an array.
C) When an array is created, the number of elements must be placed in square brackets following the type of element being stored.
D) The new keyword should be used to create an array.

Points Earned: 1.0/1.0
Correct Answer(s): A




2. Consider the class below:

public class Test
{
public static void Main( String[] args )
{
int[] a;
a = new int[ 10 ];

for ( int i = 0; i < a.Length; i++ )
a[ i ] = i + 1 * 2;

int result = 0;
for ( int i = 0; i < a.Length; i++ )
result += a[ i ];

Console.WriteLine( "Result is: {0}", result );
} // end Main
} // end class Test

The output of this C# program will be:


A) Result is: 62
B) Result is: 64
C) Result is: 65
D) Result is: 67

Points Earned: 1.0/1.0
Correct Answer(s): C




3. Arrays may have ____ dimensions.
A) one
B) two
C) more than two
D) All of the above.

Points Earned: 1.0/1.0
Correct Answer(s): D




4. Which of the following correctly declares and allocates an array of double values?
A) double A[15];
B) double() A = new double[15];
C) double[] A = new double[25];
D) All of the above.

Points Earned: 1.0/1.0
Correct Answer(s): C




5. Consider the code segment below. Which of the following statements is not true?

int[] g;
g = new int[ 23 ];
A) The first statement declares an array reference.
B) The value of g[ 3 ] is -1.
C) The second statement creates the array.
D) g is a reference to an array of integers.

Points Earned: 1.0/1.0
Correct Answer(s): B




6. Arrays are ____ data structures.
A) constant
B) dynamic
C) static
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): C




7. Consider the class below:

public class Test
{
public static void Main( String[] args )
{
int[] a = { 99, 22, 11, 3, 11, 55, 44, 88, 2, -3 };

int result = 0;
for ( int i = 0; i < a.Length; i++ )
{
if ( a[ i ] > 30 )
result += a[ i ];
} // end for

Console.WriteLine( "Result is: {0}", result );
} // end Main
} // end class Test

The output of this C# program will be:


A) Result is: 280
B) Result is: 286
C) Result is: 154
D) Result is: 332

Points Earned: 1.0/1.0
Correct Answer(s): B




8. Constant variables also are called ____.
A) write-only variables
B) finals
C) named constants
D) All of the above

Points Earned: 1.0/1.0
Correct Answer(s): C




9. The number positioned in square brackets after an array name is the ____ of an item.
A) value
B) position
C) size
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): B




10. Which of the following correctly accesses the 13th element of array Book?
A) Book[0] + 13
B) Book[13]
C) Book[12]
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): C




11. Arrays are allocated with the keyword .
A) new
B) array
C) mem
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): A




12. An array can be supplied values upon declaration by providing an ____.
A) initializer list
B) index
C) array allocation
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): A




13. Invalid possibilities for array indices include ____.
A) positive integers
B) non-consecutive integers
C) zero
D) negative integers

Points Earned: 1.0/1.0
Correct Answer(s): D




14. Which of the following will not produce a compiler error?
A) Changing the value of a constant after it is declared.
B) Changing the value at a given index of an array after it is created.
C) Using a final variable before it is initialized.
D) All of the above will produce compiler errors.

Points Earned: 1.0/1.0
Correct Answer(s): B




15. Which of the following initializer lists would correctly set the elements of array n?
A) int[] n = { 1, 2, 3, 4, 5 };
B) array n[ int ] = { 1, 2, 3, 4, 5 };
C) int n[ 5 ] = { 1; 2; 3; 4; 5 };
D) int n = new int( 1, 2, 3, 4, 5 );

Points Earned: 1.0/1.0
Correct Answer(s): A




16. Constants are declared using keyword ____.
A) static
B) const
C) dynamic
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): B




17. Consider the array:

s[ 0 ] = 7
s[ 1 ] = 0
s[ 2 ] = -12
s[ 3 ] = 9
s[ 4 ] = 10
s[ 5 ] = 3
s[ 6 ] = 6

The value of s[ s[ 6 ] - s[ 5 ] ] is:
A) 3
B) 0
C) 0
D) 9

Points Earned: 1.0/1.0
Correct Answer(s): D




18. A programmer must do the following before using an array:
A) create then reference the array
B) create then declare the array
C) declare then create the array
D) declare then reference the array

Points Earned: 0.0/1.0
Correct Answer(s): C




19. What do the following statements do?

double[] array;
array = new double[ 14 ];
A) Creates a double array containing 14 elements.
B) Declares but does not create a double array.
C) Creates a double array containing 13 elements.
D) Creates a double array containing 15 elements.

Points Earned: 1.0/1.0
Correct Answer(s): A




20. Which of the following statements about arrays are true?

A. Arrays are a group of variables that all have the same type.
B. Elements are located by index or subscript.
C. The length of an array c is determined by the expression c.Length.
D. The zeroth element of array c is specified by c[ 0 ].
A) A, B, D.
B) A, B, C, D.
C) A, C, D.
D) C, D.

Points Earned: 1.0/1.0
Correct Answer(s): B




21. Which expression adds 1 to the element of array arrayName at index i, assuming the array is of type int?
A) ++arrayName[ i ]
B) arrayName++[ i ]
C) arrayName[ i++ ]
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): A




22. Attempting to access an array element out of the bounds of an array, causes a(n) ____ to occur.
A) IndexOutOfRangeException.
B) ArrayElementOutOfBoundsException.
C) ArrayOutOfBoundsException.
D) ArrayException.

Points Earned: 1.0/1.0
Correct Answer(s): A




23. Rectangular arrays are often used to represent tables of values consisting of information arranged in:
A) rows
B) columns
C) both rows and columns
D) None of the above

Points Earned: 1.0/1.0
Correct Answer(s): C




24. The foreach repetition structure requires the programmer provide an array and a variable for the purpose of:
A) preventing the structure from going past the end of the array
B) storing the value of each element that is traversed
C) acting as a counter to traverse the array
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): B




25. What is the proper foreach header format?
A) ( foreach type_identifer in arrayName )
B) foreach ( arrayName )
C) foreach ( type_identifer in arrayName )
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): C




26. Consider array items, which contains the values 0, 2, 4, 6 and 8.
If method ChangeArray is called with the method call ChangeArray( items, items[ 2 ] ),
what values are stored in items after the method has finished executing?

public static void ChangeArray( int[] passedArray, int value )
{
passedArray[ value ] = 12;
value = 5;
} // end method ChangeArray


A) 0, 2, 12, 6, 8
B) 0, 2, 4, 6, 12
C) 0, 2, 5, 6, 12
D) 0, 2, 4, 6, 5

Points Earned: 1.0/1.0
Correct Answer(s): B




27. Which method call does the method header void ModifyArray(double[] B) represent? Assume that the array being passed in is already defined and is called list.
A) ModifyArray( double list[] )
B) ModifyArray( double[] list )
C) ModifyArray( double[] : list )
D) ModifyArray( list )

Points Earned: 1.0/1.0
Correct Answer(s): D




28. What can foreach statements iterate through?
A) databases
B) both arrays and collections
C) collections only
D) arrays only

Points Earned: 1.0/1.0
Correct Answer(s): B




29. The keyword _______ overrides an existing method with the same signature.
A) overrule
B) replace
C) override
D) supersede

Points Earned: 1.0/1.0
Correct Answer(s): C




30. What is the method header for passing in the variable that holds a reference to an array of Strings?
A) method_name( ref String[] array)
B) method_name( String[] ref array)
C) method_name( String[] )
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): A




31. There are two types of multidimensional arrays:
A) quadrangular and rectangular
B) rectangular and jagged
C) quadrangular and jagged
D) None of the above

Points Earned: 1.0/1.0
Correct Answer(s): B




32. Which function is called when an object is used where a string should be?
A) TranslateToString()
B) ConvertToString()
C) String()
D) ToString()

Points Earned: 1.0/1.0
Correct Answer(s): D




33. If you want to pass an array element into a method by reference, what will you need to do?
A) It always passes the element as a reference automatically.
B) Use the keyword ref and/or out.
C) All of the above.
D) None of the above, passing in by reference of an array element is only possible if the array type is a reference type.

Points Earned: 1.0/1.0
Correct Answer(s): B




34. Passing a reference type by value is done to protect:
A) the original object from being modified
B) the reference itself from being modified
C) data outside the bounds of an array
D) All of the above.

Points Earned: 1.0/1.0
Correct Answer(s): B




35. In rectangular array items, which expression below retrieve the value at row 3 and column 5?
A) items[ 3 ].[ 4 ]
B) items[ 3 ][ 4 ]
C) items[ 3[ 4 ] ]
D) items[ 3, 4 ]

Points Earned: 1.0/1.0
Correct Answer(s): D




36. Consider integer array values, which contains 5 elements. Which statements successfully swap the contents of the array at index 3 and index 4?
A)
values[ 3 ] = values[ 4 ];
values[ 4 ] = values[ 3 ];
B)
int temp = values[ 3 ];
values[ 3 ] = values[ 4 ];
values[ 4 ] = values[ 3 ];
C)
int temp = values[ 3 ];
values[ 3 ] = values[ 4 ];
values[ 4 ] = temp;
D)
values[ 4 ] = values[ 3 ];
values[ 3 ] = values[ 4 ];

Points Earned: 1.0/1.0
Correct Answer(s): C




37. Suppose that class Book has been defined. Which set of statements creates an array of Book objects? Assume numberElements holds a positive integer.
A)
Book[] books;
books = new Book[ numberElements ];
B)
Book[] books;
books = new Book()[ numberElements ];
C)
new Book() books[];
books = new Book[ numberElements ];
D)
All three achieve the desired result.

Points Earned: 1.0/1.0
Correct Answer(s): A




38. Which foreach header represents iterating through an array of int named numbers?
A) foreach ( number in numbers )
B) foreach ( int number in int[] numbers )
C) foreach ( numbers )
D) foreach ( int number in numbers )

Points Earned: 1.0/1.0
Correct Answer(s): D




39. Which of the following correctly declares and initializes a two-dimensional array of integers?
A) int[,] sum = new int[3, 4];
B) int[] sum = new int[2, 4];
C) int sum[] = new int[2, 2];
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): A




40. Local variables can be implicitly typed by replacing their type with keyword ______.
A) var
B) unk
C) type
D) dim

Points Earned: 1.0/1.0
Correct Answer(s): A




41. Values in an array can be totaled by using the ArrayTotal method.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




42. Arrays remain the same size once they are created.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




43. A constant must be initialized in the same statement where it is declared and cannot be modified.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




44. The first element in every array is the 0th element.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




45. Each reference in an array of references is pointed to null by default when the array is allocated.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




46. The position number in parentheses is formally called an index.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




47. Arrays are data structures consisting of data items of different types.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




48. Using arrays can be an elegant way to avoid using sets of counter variables and switch statements.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




49. An array must be declared and allocated in the same statement.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




50. Arrays are only designed to hold primitive data types and Strings.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




51. Arrays can be declared to hold only primitive data types.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




52. When values are provided upon declaration of an array, the new keyword is not required.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




53. An array must be counted manually to determine how many items it holds.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




54. In an array of reference types, each element may be a reference to a different type.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




55. C# automatically performs bounds checking to ensure the program doesn’t access data outside the bounds of an array.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




56. Constants are usually denoted by variable names in all capital letters.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




57. Programs sometimes use a series of counter variables to summarize data.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




58. An array is a group of contiguous memory locations that all have the same name and type.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




59. The index of an array must be an integer; it cannot include variables or expres­sions.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




60. The number of elements in the array must be specified in brackets after the array name in the declaration.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




61. Changes made to an entire array that has been passed to a method will not affect the original values of the array.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




62. When a method receives a reference-type object parameter by value, the object is actually passed by value.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




63. Jagged arrays are maintained as arrays of arrays.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




64. Depending on the way one implements a foreach loop, it can behave just like a regular for loop.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




65. One could iterate through multi-dimensional arrays by using nested for loops.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




66. Instance variables can be implicitly typed if they are initialized in the constructor.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




67. When accessing an element of an array, operations (calculations) are not allowed inside the brackets of an array.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




68. The foreach repetition structure can only be used with single-dimensional arrays.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




69. Multi-dimensional arrays require two or more indices to identify particular elements.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




70. Tables are often represented with rectangular arrays.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




71. By convention, the first set of brackets of a two-dimensional array identifies an element’s column and the second identifies the row.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




72. To protect the reference of an array, it should be passed to methods with key­word val.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




73. The foreach repetition structure is useful when the indices of the elements in an array are not important.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




74. The foreach loop is rarely used because it is more complicated to use than the for loop.
A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




75. Passing a reference with keyword ref gives the called method control over the passed reference itself.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




76. The foreach repetition structure is a simple structure used to traverse an array.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




77. Individual elements of arrays are passed to methods by value.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




78. Arrays are not limited to just simple types, but can hold reference types as well.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




79. When dealing with multi-dimensional arrays, each “row” must be the same size.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




80. To pass an array argument to a method, specify the name of the array followed by empty brackets.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False

midterm

1. C# is the only language available for programming .NET applications.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




2. A machine-language program requires translation before it can be run on a computer.
A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




3. C# is an object-oriented languageA) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




4. The Visual C# compiler translates high-level-language programs into SMIL.
A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




5. Select the matching word or acronym.
A. compilers
B. UNIX
C. assembly
D. machine
E. IDE
F. XML
G. programs
H. SOAP


ABCDEFGHComputers can directly understand only their native ___ language, which is composed only of 1s and 0s.
ABCDEFGHWeb services use ____ to send information over the Internet.
ABCDEFGHVisual Studio is a(n) ______ in which C# programs are developed.
ABCDEFGHComputers process data under the control of sets of instructions called computer _______.
ABCDEFGHC is widely known as the development language of the ____ operating system.
ABCDEFGHWeb service use ____ to markup information for transmission over the Internet.
ABCDEFGHPrograms that translate high-level-language programs into machine language are called _____.
ABCDEFGHThe three types of computer languages discussed in the textbook are high-level languages, machine languages and ____ languages.
Points Earned: 7.0/7.0
Correct Answer(s): machine : Computers can directly understand only their native ___ language, which is composed only of 1s and 0s. , programs : Computers process data under the control of sets of instructions called computer _______., assembly : The three types of computer languages discussed in the textbook are high-level languages, machine languages and ____ languages., compilers : Programs that translate high-level-language programs into machine language are called _____. , IDE : Visual Studio is a(n) ______ in which C# programs are developed. , UNIX : C is widely known as the development language of the ____ operating system. , XML : Web service use ____ to markup information for transmission over the Internet. , SOAP : Web services use ____ to send information over the Internet.




6. A compiler translates high-level language programs into target-language programs.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




7. The toolbar icons represent various menu commands.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




8. Visual C# files use the file extension .csharp.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




9. Control properties can be modified only by writing code.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




10. The IDE's title bar displays the IDE's mode.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




11. Select the matching word, phrase or acronym for each question.
A. newline
B. if
C. start
D. comma
E. colon
F. Main
G. blank lines
H. Console.Write
I. semicolon
J. keywords
K. STX
L. brace
M. EOF
N. //


ABCDEFGHIJKLMNThe escape sequence \n represents the ____ character, which causes the cursor to position to the beginning of the next line on the screen.
ABCDEFGHIJKLMNMethods WriteLine and ____ display information in the console window.
ABCDEFGHIJKLMNNewline, space and tab characters and ____ are called whitespace characters.
ABCDEFGHIJKLMN____ are reserved for use by C#.
ABCDEFGHIJKLMNThe ____ statement is used to make decisions.
ABCDEFGHIJKLMN____ begins a single-line comment.
ABCDEFGHIJKLMNA left ____ begins the body of every method and a right ____ ends the body of every method.
ABCDEFGHIJKLMNMost C# statements end with a(n) ____.
ABCDEFGHIJKLMNC# applications begin execution at method ____.
Points Earned: 8.0/8.0
Correct Answer(s): brace : A left ____ begins the body of every method and a right ____ ends the body of every method., semicolon : Most C# statements end with a(n) ____., newline : The escape sequence \n represents the ____ character, which causes the cursor to position to the beginning of the next line on the screen., if : The ____ statement is used to make decisions., // : ____ begins a single-line comment., blank lines : Newline, space and tab characters and ____ are called whitespace characters., keywords : ____ are reserved for use by C#., Main : C# applications begin execution at method ____., Console.Write : Methods WriteLine and ____ display information in the console window.




12. The number of arguments in the method call must match the number of parameters in the method declaration's parameter list.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




13. The body of any method or property is delimited by left and right braces.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




14. Reference-type instance variables are initialized by default to the value null.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




15. In general, instance variables are accessible to all methods of the class.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




16. After defining a property, you can use it the same way you use a method, but with empty parentheses, because no arguments are passed to a property.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




17. A using directive is not required when one class in a namespace uses another in the same namespace.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




18. An instance variable is declared in a class, but not in the body of any of the class's methods.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




19. Variables declared in the body of a particular method are known as instance variables and can be used in all methods of the class.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




20. Consider each statement separately and independently. For each, assume that a has a value of 120 and x has a value of 5 before the statement is executed. What will the variables' values be after they execute?
A. a = 20, x = 6
B. a = 720, x = 6
C. a = 30, x = 4
D. a = 24, x = 5
E. a = 30, x = 5
F. a = 480, x = 4
G. The statement has invalid syntax.
H. a = 600, x = 4
I. a = 30, x = 6
J. a = 20, x = 4
K. a = 20, x = 5
L. a = 480, x = 5
M. a = 600, x = 6
N. a = 24, x = 4
O. a = 24, x = 6
P. a = 720, x = 5
Q. a = 480, x = 6
R. a = 720, x = 4
S. a = 600, x = 5
T. The statement has valid syntax, but none of the above is correct. The statement has valid syntax, but none of the above is correct.


ABCDEFGHIJKLMNOPQRSTa /= x;
ABCDEFGHIJKLMNOPQRSTa *= ++x;
ABCDEFGHIJKLMNOPQRSTa *= x++;
ABCDEFGHIJKLMNOPQRSTa /= --x;
ABCDEFGHIJKLMNOPQRSTa /= x--;
ABCDEFGHIJKLMNOPQRSTa *= x;
Points Earned: 6.0/6.0
Correct Answer(s): a = 600, x = 6 : a *= x++;, a = 24, x = 4 : a /= x--;, a = 720, x = 6 : a *= ++x;, a = 30, x = 4 : a /= --x;, a = 600, x = 5 : a *= x;, a = 24, x = 5 : a /= x;




21. The break statement is required in every case of a switch selection statement to exit the switch properly.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




22. The expression ( x > y && a < b ) is true if either the expression x > y is true or the expression a < b is true.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




23. Select the best word or operator to fill the blank.
A. break
B. false
C. dynamic
D. while
E. if
F. after
G. before
H. ||
I. switch
J. &&
K. true
L. continue
M. static
N. for


ABCDEFGHIJKLMNThe do...while statement tests the loop-continuation condition ____ executing the loop's body.
ABCDEFGHIJKLMNThe ___ statement, when executed in a repetition statement, skips the remaining statements in the loop body and proceeds with the next iteration of the loop.
ABCDEFGHIJKLMNThe ____ operator can be used to ensure that two conditions are both true before choosing a certain path of execution.
ABCDEFGHIJKLMNIf the loop-continuation condition in a for header is initially ____, the for statement's body does not execute.
ABCDEFGHIJKLMNThe ____ statement selects among multiple actions based on the possible values of an integer variable or expression.
ABCDEFGHIJKLMNMethods that perform common tasks and do not need to be called on objects are called ____ methods.
ABCDEFGHIJKLMNTypically, ____ statements are used for sentinel-controlled repetition.
ABCDEFGHIJKLMNTypically, ____ statements are used for counter-controlled repetition.
Points Earned: 7.0/7.0
Correct Answer(s): for : Typically, ____ statements are used for counter-controlled repetition., while : Typically, ____ statements are used for sentinel-controlled repetition., after : The do...while statement tests the loop-continuation condition ____ executing the loop's body., switch : The ____ statement selects among multiple actions based on the possible values of an integer variable or expression., continue : The ___ statement, when executed in a repetition statement, skips the remaining statements in the loop body and proceeds with the next iteration of the loop., && : The ____ operator can be used to ensure that two conditions are both true before choosing a certain path of execution., false : If the loop-continuation condition in a for header is initially ____, the for statement's body does not execute., static : Methods that perform common tasks and do not need to be called on objects are called ____ methods.




24. Assume the integer variables sum and count have been declared. This code sums the odd integers between 1 and 99, inclusive, using a for statement.

sum = 0;
for ( count = 1; count <= 99; count += 2 )
sum += count;

A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




25. Listing cases consecutively with no statements between them enables the cases to perform the same set of statements.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




26. The integer after the comma (,) in a format item ( e.g., {0,4} ) indicates the field width of the displayed string.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




27. An int must be explicitly casted to which of the following?
A) float
B) bool
C) sbyte
D) double

Points Earned: 1.0/1.0
Correct Answer(s): C




28. Methods can return at most one value.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




29. To provide a better understanding of a program, all methods and classes should be written by the programmer.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




30. Methods that call themselves are known as ________.
A) reiterative
B) self-calling
C) recursive
D) repeat-calling

Points Earned: 1.0/1.0
Correct Answer(s): C




31. Random-number generator scaling is the process of:
A) causing each number in a range to have equal likelihood of being generated
B) modifying the range from which a number will be generated
C) calculating a sequence of numbers to be generated
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): B




32. The parameter list in the method header and the arguments in the method call must agree in:
A) number
B) type
C) order
D) all of the above

Points Earned: 1.0/1.0
Correct Answer(s): D




33. When may an application omit the string[] args parameter from the Main header?
A) when the application does not need to use strings
B) when the application does not take command-line arguments
C) when the application does not output any strings
D) All of the above

Points Earned: 1.0/1.0
Correct Answer(s): B




34. Methods should be large and perform as many tasks as possible.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




35. Methods are called by writing the name of the method followed by ____ enclosed in parentheses.
A) a condition
B) arguments
C) a counter
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): B




36. Which of the following statements describes block scope?
A) It limits label scope to only the method in which it is declared.
B) It begins at the identifier's declaration and ends at the terminating right brace (}).
C) It begins at the opening { of the class declaration and terminates at the closing }
D) It is valid for one statement only.

Points Earned: 1.0/1.0
Correct Answer(s): B




37. When a method call is within another method call, the calls will execute from the outside in.A) True
B) False

Points Earned: 0.0/1.0
Correct Answer(s): False




38. Which keyword can programmers use to break out of a void method?
A) continue
B) break
C) next
D) return

Points Earned: 1.0/1.0
Correct Answer(s): D




39. Many prepackaged classes and methods are provided in the .NET FCL, an acronym for the .
A) Framework Class Library
B) Framework Class Listing
C) Form Class Library
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): A




40. Stacks are _____________ data structures.
A) FIFO
B) Random
C) LIFO
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): C




41. The Math class only provides methods.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




42. Arrays can be declared to hold only primitive data types.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




43. Constants are declared using keyword ____.
A) static
B) const
C) dynamic
D) None of the above.

Points Earned: 1.0/1.0
Correct Answer(s): B




44. Which of the following statements about arrays are true?

A. Arrays are a group of variables that all have the same type.
B. Elements are located by index or subscript.
C. The length of an array c is determined by the expression c.Length.
D. The zeroth element of array c is specified by c[ 0 ].
A) C, D.
B) A, B, C, D.
C) A, B, D.
D) A, C, D.

Points Earned: 1.0/1.0
Correct Answer(s): B




45. Values in an array can be totaled by using the ArrayTotal method.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




46. What can foreach statements iterate through?
A) both arrays and collections
B) arrays only
C) collections only
D) databases

Points Earned: 1.0/1.0
Correct Answer(s): A




47. There are two types of multidimensional arrays:
A) quadrangular and rectangular
B) rectangular and jagged
C) quadrangular and jagged
D) None of the above

Points Earned: 1.0/1.0
Correct Answer(s): B




48. An array is a group of contiguous memory locations that all have the same name and type.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




49. Depending on the way one implements a foreach loop, it can behave just like a regular for loop.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): True




50. Which of the following initializer lists would correctly set the elements of array n?
A) int n[ 5 ] = { 1; 2; 3; 4; 5 };
B) array n[ int ] = { 1, 2, 3, 4, 5 };
C) int n = new int( 1, 2, 3, 4, 5 );
D) int[] n = { 1, 2, 3, 4, 5 };

Points Earned: 0.0/1.0
Correct Answer(s): D




51. Instance variables can be implicitly typed if they are initialized in the constructor.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




52. Attempting to access an array element out of the bounds of an array, causes a(n) ____ to occur.
A) ArrayOutOfBoundsException.
B) ArrayElementOutOfBoundsException.
C) IndexOutOfRangeException.
D) ArrayException.

Points Earned: 1.0/1.0
Correct Answer(s): C




53. The position number in parentheses is formally called an index.A) True
B) False

Points Earned: 1.0/1.0
Correct Answer(s): False




54. Which method call does the method header void ModifyArray(double[] B) represent? Assume that the array being passed in is already defined and is called list.
A) ModifyArray( list )
B) ModifyArray( double[] : list )
C) ModifyArray( double list[] )
D) ModifyArray( double[] list )

Points Earned: 1.0/1.0
Correct Answer(s): A




55. Which of the following correctly declares and allocates an array of double values?
A) double A[15];
B) double() A = new double[15];
C) double[] A = new double[25];
D) All of the above.

Points Earned: 1.0/1.0
Correct Answer(s): C




56. Consider the class below:

public class Test
{
public static void Main( String[] args )
{
int[] a = { 99, 22, 11, 3, 11, 55, 44, 88, 2, -3 };

int result = 0;
for ( int i = 0; i < a.Length; i++ )
{
if ( a[ i ] > 30 )
result += a[ i ];
} // end for

Console.WriteLine( "Result is: {0}", result );
} // end Main
} // end class Test

The output of this C# program will be:


A) Result is: 280
B) Result is: 154
C) Result is: 286
D) Result is: 332

Points Earned: 1.0/1.0
Correct Answer(s): C