Wednesday, June 3, 2009

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

No comments:

Post a Comment