MC Flashcards

(154 cards)

1
Q

Programming languages such as C#, Java, and Visual Basic are ______________ languages.
a. machine
b. high-level
c. low-level
d. uninterpreted

A

Correct Answer: b. high-level

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

A program that translates high-level programs into intermediate or machine code is a(n) ______________ .
a. mangler
b. compactor
c. analyst
d. compiler

A

Correct Answer: d. compiler

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

The grammar and spelling rules of a programming language constitute its _____________ .
a. logic
b. variables
c. class
d. syntax

A

Correct Answer: d. syntax

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Variables are _______________ .
a. named memory locations
b. unexpected results
c. grammar rules
d. operations

A

Correct Answer: a. named memory locations

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Programs in which you create and use objects that have attributes similar to their real-world counterparts are known as ______________ programs.
a. procedural
b. logical
c. object-oriented
d. authentic

A

Correct Answer: c. object-oriented

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Which of the following pairs is an example of a class and an object, in that order?
a. University and Yale
b. Chair and desk
c. Clydesdale and horse
d. Maple and tree

A

Correct Answer: a. University and Yale

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

The technique of packaging an object’s attributes into a cohesive unit that can be used as an undivided entity is ______________ .
a. inheritance
b. encapsulation
c. polymorphism
d. interfacing

A

Correct Answer: b. encapsulation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Which of the following languages is least similar to C#?
a. Java
b. Visual Basic
c. C++
d. machine language

A

Correct Answer: d. machine language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

A series of characters that appears within double quotation marks is a(n) ______________ .
a. method
b. interface
c. argument
d. literal string

A

Correct Answer: d. literal string

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

The C# method that produces a line of output on the screen and then positions the cursor on the next line is ________________ .
a. WriteLine()
b. PrintLine()
c. DisplayLine()
d. OutLine()

A

Correct Answer: a. WriteLine()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Which of the following is a class?
a. System
b. Console
c. void
d. WriteLine()

A

Correct Answer: b. Console

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

In C#, a container that groups similar classes is a(n) ___________________ .
a. superclass
b. method
c. namespace
d. identifier

A

Correct Answer: c. namespace

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Every method in C# contains a _________________________ .
a. header and a body
b. header and a footer
c. variable and a class
d. class and an object

A

Correct Answer: a. header and a body

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Which of the following is a method?
a. namespace
b. class
c. Main()
d. static

A

Correct Answer: c. Main()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

In C#, an identifier _________________________ .
a. must begin with an underscore
b. can contain digits
c. must be no more than 16 characters
d. can contain only lowercase letters

A

Correct Answer: b. can contain digits

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Which of the following identifiers is not legal in C#?
a. per cent increase
b. annualReview
c. HTML
d. alternativetaxcredit

A

Correct Answer: a. per cent increase

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

The text of a program you write is called _________________________.
a. object code
b. source code
c. machine language
d. executable documentation

A

Correct Answer: b. source code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Programming errors such as using incorrect punctuation or misspelling words are collectively known as ____________________ errors.
a. syntax
b. logical
c. executable
d. fatal

A

Correct Answer: a. syntax

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

A comment in the form / this is a comment / is a(n)___.
a. XML comment
b. block comment
c. executable comment
d. line comment

A

Correct Answer: b. block comment

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

If a programmer inserts using static System.Console; at the top of a C# program, which of the following can the programmer use as an alternative to System.Console.WriteLine(“Hello”);?
a. System(“Hello”);
b. WriteLine(“Hello”);
c. Console.WriteLine(“Hello”);
d. Console(“Hello”);

A

Correct Answer: b. WriteLine(“Hello”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

When you use a number such as 45 in a C# program, the number is a ______________.
a. figurative constant
b. literal constant
c. literal variable
d. figurative variable

A

Correct Answer: b. literal constant

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

A variable declaration must contain all of the following except a(n) ______________.
a. data type
b. identifier
c. assigned value
d. ending semicolon

A

Correct Answer: c. assigned value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Which of the following is true of variable declarations?
a. Two variables of different types can be declared in the same statement.
b. Two variables of the same type can be declared in the same statement.
c. Two variables of the same type must be declared in the same statement.
d. Two variables of the same type cannot coexist in a program.

A

Correct Answer: b. Two variables of the same type can be declared in the same statement.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

Assume that you have two variables declared as int var1 = 3; and int var2 = 8;. Which of the following would display 838?
a. WriteLine(“{0}{1}{2}”, var1, var2);
b. WriteLine(“{0}{1}{0}”, var2, var1);
c. WriteLine(“{0}{1}{2}”, var2, var1);
d. WriteLine(“{0}{1}{0}”, var1, var2);

A

Correct Answer: b. WriteLine(“{0}{1}{0}”, var2, var1);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Assume that you have a variable declared as int var1 = 3;. Which of the following would display X 3X? a. WriteLine("X{0}X", var1); b. WriteLine("X{0,2}X", var1); c. WriteLine("X{2,0}X", var1); d. WriteLine("X{0}{2}", var1);
Correct Answer: b. WriteLine("X{0,2}X", var1);
26
Assume that you have a variable declared as int var1 = 3;. What is the value of 22 % var1? a. 21 b. 7 c. 1 d. 0
Correct Answer: c. 1
27
Assume that you have a variable declared as int var1 = 3;. What is the value of 22 / var1? a. 21 b. 7.333 c. 7 d. 1
Correct Answer: c. 7
28
What is the value of the expression 4 + 2 * 3? a. 0 b. 10 c. 18 d. 36
Correct Answer: b. 10
29
Assume that you have a variable declared as int var1 = 3;. If var2 = ++var1, what is the value of var2? a. 2 b. 3 c. 4 d. 5
Correct Answer: c. 4
30
Assume that you have a variable declared as int var1 = 3;. If var2 = var1++, what is the value of var2? a. 2 b. 3 c. 4 d. 5
Correct Answer: b. 3
31
A variable that can hold the two values true and false is of type ______________. a. char b. int c. bool d. double
Correct Answer: c. bool
31
Which of the following is not a C# comparison operator? a. => b. != c. == d. <
Correct Answer: a. =>
32
What is the value of the expression 6 >= 7? a. 0 b. 1 c. true d. false
Correct Answer: d. false
33
Which of the following C# types cannot contain floating-point numbers? a. float b. double c. decimal d. int
Correct Answer: d. int
34
Assume that you have declared a variable as double hourly = 13.00;. What will the statement WriteLine(hourly); display? a. 13 b. 13.0 c. 13.00 d. 13.000000
Correct Answer: a. 13
35
Assume that you have declared a variable as double salary = 45000.00;. Which of the following will display $45,000? a. WriteLine(salary.ToString("c")); b. WriteLine(salary.ToString("c0")); c. WriteLine(salary); d. two of these
Correct Answer: b. WriteLine(salary.ToString("c0"));
36
When you perform arithmetic operations with operands of different types, such as adding an int and a float, ______________. a. C# chooses a unifying type for the result b. you must choose a unifying type for the result c. you must provide a cast d. you receive an error message
Correct Answer: a. C# chooses a unifying type for the result
37
Unicode is _______________. a. an object-oriented language b. a subset of the C# language c. a 16-bit coding scheme d. another term for hexadecimal
Correct Answer: c. a 16-bit coding scheme
38
Which of the following declares a variable that can hold the word "computer"? a. string device = 'computer'; b. string device = "computer"; c. char device = 'computer'; d. char device = "computer";
Correct Answer: b. string device = "computer";
39
Which of the following compares two string variables named string1 and string2 to determine if their contents are equal? a. string1 = string2 b. string1 == string2 c. Equals.String(string1, string2) d. two of the above
Correct Answer: b. string1 == string2
40
Which of the following is a GUI object that provides an interface for collecting, displaying, and delivering information and that contains other controls? a. Button b. Form c. TextBox d. Label
Correct Answer: b. Form
41
In the Visual Studio IDE main window, where does the menu bar lie? a. vertically along the left border b. vertically along the right border c. horizontally across the bottom of the window d. horizontally across the top of the window
Correct Answer: d. horizontally across the top of the window
42
In the IDE, the area where you visually construct a Form is the ______________ . a. Toolbox b. Form Designer c. Easel d. Sandbox
Correct Answer: b. Form Designer
43
When you create a new Windows Forms project, by default the first Form you see is named ______________ . a. Form b. FormA c. Form1 d. FormAlpha
Correct Answer: c. Form1
44
The Form class has ______________ properties. a. three b. ten c. about 100 d. about 1000
Correct Answer: c. about 100
45
Which of the following is not a Form property? a. BackColor b. Size c. Text d. ProjectName
Correct Answer: d. ProjectName
46
Which of the following is a legal Form Name property value? a. PayrollForm b. Payroll Form c. either of the above d. none of the above
Correct Answer: a. PayrollForm
47
Which of the following is a legal Form Text property value? a. PayrollForm b. Payroll Form c. either of the above d. none of the above
Correct Answer: c. either of the above
48
Which of the following does not appear in the IDE’s Toolbox list? a. Label b. Button c. Text d. TextBox
Correct Answer: c. Text
49
After you have dragged a Button onto a Form in the IDE, you can double-click it to ______________ a. delete it b. view its properties c. create a method that executes when a user clicks the Button d. increase its size
Correct Answer: c. create a method that executes when a user clicks the Button
50
The button1_Click() method that is generated by the IDE ______________ . a. has a private access specifier b. is nonstatic c. contains parameters between its parentheses d. all of the above
Correct Answer: d. all of the above
51
A(n) ______________ is generated when a user interacts with a GUI object. a. error b. occasion c. method d. event
Correct Answer: d. event
52
If you create a Button named yesButton, the default name of the method that responds to clicks on it is ______________ . a. button1_Click() b. yesButton_Method() c. click_YesButton() d. yesButton_Click()
Correct Answer: d. yesButton_Click()
53
Statements allowed in a Click() method include ______________ . a. variable declarations b. arithmetic statements c. both of the above d. none of the above
Correct Answer: c. both of the above
54
______________ are controls through which a user can enter input data in a GUI application. a. Labels b. Tags c. Tickets d. TextBoxes
Correct Answer: d. TextBoxes
55
The value in a TextBox is ______________ . a. an int b. a double c. a string d. It might be any of the above.
Correct Answer: c. a string
56
Which of the following is a legal and conventional name for a TextBox? a. Salary TextBox b. salaryTextBox c. both of the above d. none of the above
Correct Answer: b. salaryTextBox
57
The process of changing a program’s internal structure without changing the way the program works is ______________ . a. compiling b. debugging c. code refactoring d. systems analysis
Correct Answer: c. code refactoring
58
If you inadvertently create a Click() method for a control that should not generate a click event, you can successfully eliminate the method by ______________ . a. deleting the method code from the Form1.cs file b. eliminating the method from the Events list in the Properties window c. adding the method to the Discard window d. making the method a comment by placing two forward slashes at the start of each line
Correct Answer: b. eliminating the method from the Events list in the Properties window
59
Of the following, the most significant difference between many console applications and GUI applications is ______________ . a. their appearance b. their ability to accept input c. their ability to perform calculations d. their ability to be created using C#
Correct Answer: a. their appearance
60
What is the output of the following code segment? int a = 3, b = 4; if(a == b) Write("X"); WriteLine("Y"); a. X b. Y c. XY d. nothing
Correct Answer: b. Y
61
What is the output of the following code segment? int a = 3, b = 4; if(a < b) { Write("Y"); WriteLine("Z"); } a. Y b. Z c. YZ d. nothing
Correct Answer: c. YZ
62
What is the output of the following code segment? int a = 3, b = 4; if(a > b) Write("Up"); else WriteLine("Down"); a. Up b. Down c. UpDown d. nothing
Correct Answer: b. Down
63
If the following code segment compiles correctly, what do you know about the variable x? if(x) WriteLine("OK"); a. x is an integer variable. b. x is a Boolean variable. c. x is greater than 0. d. none of these
Correct Answer: b. x is a Boolean variable.
64
What is the output of the following code segment? int c = 6, d = 12; if(c > d); Write("Green"); WriteLine("Yellow"); a. Green b. Yellow c. GreenYellow d. nothing
Correct Answer: c. GreenYellow
65
What is the output of the following code segment? int c = 6, d = 12; if(c < d) if(c > 8) Write("Blue"); else Write("Red"); else Write("Green"); a. Blue b. Red c. Green d. nothing
Correct Answer: b. Red
66
What is the output of the following code segment? int e = 5, f = 10; if(e < f && f < 0) Write("Red"); else Write("Orange"); a. Red b. Orange c. RedOrange d. nothing
Correct Answer: b. Orange
67
What is the output of the following code segment? int e = 5, f = 10; if(e < f || f < 0) Write("Purple"); else Write("Gold"); a. Purple b. Gold c. PurpleGold d. nothing
Correct Answer: a. Purple
68
Which of the following expressions is equivalent to the following code segment? if(g > h) if(g < k) Write("Brown"); a. if(g > h && g < k) Write("Brown"); b. if(g > h && < k) Write("Brown"); c. if(g > h || g < k) Write("Brown"); d. two of these
Correct Answer: a. if(g > h && g < k) Write("Brown");
69
Which of the following expressions assigns true to a Boolean variable named isIDValid when idNumber is both greater than 1000 and less than or equal to 9999, or else is equal to 123456? a. isIDValid = (idNumber > 1000 && idNumber <= 9999 && idNumber == 123456) b. isIDValid = (idNumber > 1000 && idNumber <= 9999 || idNumber == 123456) c. isIDValid = ((idNumber > 1000 && idNumber <= 9999) || idNumber == 123456) d. two of these
Correct Answer: c. isIDValid = ((idNumber > 1000 && idNumber <= 9999) || idNumber == 123456)
70
Which of the following expressions is equivalent to a || b && c || d? a. a && b || c && d b. (a || b) && (c || d) c. a || (b && c) || d d. two of these
Correct Answer: c. a || (b && c) || d
71
How many case labels would a switch statement require to be equivalent to the following if statement? if(v == 1) WriteLine("one"); else WriteLine("two"); a. zero b. one c. two d. impossible to tell
Correct Answer: c. two
72
In C#, falling through a switch case is most often prevented by using the ______________ statement. a. break b. default c. case d. end
Correct Answer: a. break
73
If the test expression in a switch does not match any of the case values, and there is no default value, then ______________. a. a compiler error occurs b. a runtime error occurs c. the program continues with the next executable statement d. the expression is incremented and the case values are tested again
Correct Answer: c. the program continues with the next executable statement
74
Which of the following is equivalent to the following statement? if(m == 0) d = 0; else d = 1; a. d = (m == 0) : d = 0, d = 1; b. m ? (d = 0); (d = 1); c. m == 0; d = 0; d = 1? d. d = (m == 0) ? 0 : 1;
Correct Answer: d. d = (m == 0) ? 0 : 1;
75
Which of the following C# expressions is equivalent to a < b && b < c? a. c > b > a b. a < b && c >= b c. !(b <= a) && b < c d. two of these
Correct Answer: c. !(b <= a) && b < c
76
Which of the following C# expressions means, “If itemNumber is not 8 or 9, add TAX to price”? a. if(itemNumber != 8 || itemNumber != 9) price = price + TAX; b. if(itemNumber != 8 && itemNumber != 9) price = price + TAX; c. if(itemNumber != 8 && != 9) price = price + TAX; d. two of these
Correct Answer: b. if(itemNumber != 8 && itemNumber != 9) price = price + TAX;
77
Which of the following C# expressions means, “If itemNumber is 1 or 2 and quantity is 12 or more, add TAX to price”? a. if(itemNumber = 1 || itemNumber = 2 && quantity >=12) price = price + TAX; b. if(itemNumber == 1 || itemNumber == 2 || quantity >=12) price = price + TAX; c. if(itemNumber == 1 && itemNumber == 2 && quantity >=12) price = price + TAX; d. none of these
Correct Answer: d. none of these
78
Which of the following C# expressions means, “If itemNumber is 5 and zone is 1 or 3, add TAX to price”? a. if(itemNumber == 5 && zone == 1 || zone == 3) price = price + TAX; b. if(itemNumber == 5 && (zone == 1 || zone == 3)) price = price + TAX; c. if(itemNumber == 5 && (zone == 1 || 3)) price = price + TAX; d. two of these
Correct Answer: b. if(itemNumber == 5 && (zone == 1 || zone == 3)) price = price + TAX;
78
Which of the following C# expressions results in TAX being added to price if the integer itemNumber is not 100? a. if(itemNumber != 100) price = price + TAX; b. if(!(itemNumber == 100)) price = price + TAX; c. if(itemNumber < 100 || itemNumber > 100) price = price + TAX; d. all of these
Correct Answer: d. all of these
79
A structure that allows repeated execution of a block of statements is a(n) ___________. a. sequence b. selection c. array d. loop
Correct Answer: d. loop
80
The body of a while loop can consist of _______________________. a. a single statement b. a block of statements within curly braces c. either a or b d. neither a nor b
Correct Answer: c. either a or b
81
A loop that never ends is called an ________________________ loop. a. indefinite b. interminable c. infinite d. intermediate
Correct Answer: c. infinite
82
Which of the following is not required of a loop control variable in a correctly working loop? a. It is reset to its initial value before the loop ends. b. It is initialized before the loop starts. c. It is tested. d. It is altered in the loop body.
Correct Answer: a. It is reset to its initial value before the loop ends.
83
A while loop with an empty body contains no ___________________________. a. statements b. loop control variable c. curly braces d. test within the parentheses of the while statement
Correct Answer: a. statements
84
A loop for which you do not know the number of iterations when you write it is a(n) _______________________. a. indefinite loop b. definite loop c. counted loop d. for loop
Correct Answer: a. indefinite loop
85
What is the major advantage of using a for loop instead of a while loop? a. With a for loop, it is impossible to create an infinite loop. b. The loop control variable is initialized, tested, and altered all in one place. c. It is the only way to achieve an indefinite loop. d. Unlike with a while loop, the execution of multiple statements can depend on the test condition.
Correct Answer: b. The loop control variable is initialized, tested, and altered all in one place.
86
A for loop statement must contain ____________________________. a. two semicolons b. three commas c. four dots d. five pipes
Correct Answer: a. two semicolons
87
In a for statement, the section before the first semicolon executes ______________________________. a. once b. once prior to each loop iteration c. once after each loop iteration d. one less time than the initial loop control variable value
Correct Answer: a. once
87
Which loop is most convenient to use if the loop body must always execute at least once? a. a while loop b. a for loop c. a do loop d. an if loop
Correct Answer: c. a do loop
88
The loop control variable is checked at the bottom of which kind of loop? a. a while loop b. a for loop c. a do loop d. all of the above
Correct Answer: c. a do loop
89
A for loop is an example of a(n) __________________________ loop. a. untested b. pretest c. posttest d. infinite
Correct Answer: b. pretest
90
A while loop is an example of a(n) _______________________ loop. a. untested b. pretest c. posttest d. infinite
Correct Answer: b. pretest
91
When a loop is placed within another loop, the loops are said to be ______________________. a. infinite b. bubbled c. overlapping d. nested
Correct Answer: d. nested
92
What does the following code segment display? a = 1; while (a < 5); { Write("{0} ", a); ++a; } a. 1 2 3 4 b. 1 c. 4 d. nothing
Correct Answer: d. nothing (semicolon after while(a < 5); causes an empty loop)
93
What is the output of the following code segment? s = 1; while(s < 4) ++s; Write("{0} ", s); a. 1 b. 4 c. 1 2 3 4 d. 2 3 4
Correct Answer: b. 4
94
What is the output of the following code segment? j = 5; while(j > 0) { Write("{0} ", j); j--; } a. 0 b. 5 c. 5 4 3 2 1 d. 5 4 3 2 1 0
Correct Answer: c. 5 4 3 2 1
95
What does the following code segment display? for(f = 0; f < 3; ++f); Write("{0} ", f); a. 0 b. 0 1 2 c. 3 d. nothing
Correct Answer: c. 3 (semicolon causes the loop to execute without output, then f is displayed after reaching 3)
95
What does the following code segment display? for(t = 0; t < 3; ++t) Write("{0} ", t); a. 0 b. 0 1 c. 0 1 2 d. 0 1 2 3
Correct Answer: c. 0 1 2
96
In an array, every element has the same _______________________. a. subscript b. memory location c. data type d. all of the above
Correct Answer: c. data type
97
The operator used to create objects is _______________________. a. = b. += c. new d. create
Correct Answer: c. new
98
Which of the following correctly declares an array of six integers? a. int array[6]; b. int[] array = 6; c. int[6] array; d. int[] array = new int[6];
Correct Answer: d. int[] array = new int[6];
99
The value placed within square brackets after an array name is ______________________. a. always a constant b. always a double c. called a subscript d. all of these
Correct Answer: c. called a subscript
100
If you define an array to contain 10 elements, then the highest array subscript you can use is ______________________. a. 8 b. 9 c. 10 d. 11
Correct Answer: b. 9
101
Initializing an array is _______________________ in C#. a. optional b. required c. difficult d. prohibited
Correct Answer: a. optional
102
When you declare an array of six double elements but provide no initialization values, the value of the first element is _______________________. a. 0.0 b. 1.0 c. 5.0 d. unknown
Correct Answer: a. 0.0
103
Which of the following correctly declares an array of four integers? a. int[] ages = new int[4] {20, 30, 40, 50}; b. int[] ages = new int[] {20, 30, 40, 50}; c. int[] ages = {20, 30, 40, 50}; d. all of these
Correct Answer: d. all of these
104
When an ages array is correctly initialized using the values {20, 30, 40, 50}, then the value of ages[1] is _______________________. a. 0 b. 20 c. 30 d. undefined
Correct Answer: c. 30
105
When an ages array is correctly initialized using the values {20, 30, 40, 50}, then the value of ages[4] is _______________________. a. 0 b. 4 c. 50 d. undefined
Correct Answer: d. undefined (index out of range)
106
When you declare an array as int[] temperature = {0, 32, 50, 90, 212, 451};, the value of temperature.Length is _______________________. a. 5 b. 6 c. 7 d. unknown
Correct Answer: b. 6
107
Which of the following doubles every value in a 10-element integer array named amount? a. for(int x = 9; x >= 0; --x) amount[x] *= 2; b. foreach(int number in amount) number *= 2; c. both of these d. neither of these
Correct Answer: a. for(int x = 9; x >= 0; --x) amount[x] *= 2;
108
Which of the following adds 10 to every value in a 16-element integer array named points? a. for(int sub = 0; sub > 16; ++sub) points[sub] += 10; b. foreach(int sub in points) points += 10; c. both of these d. neither of these
Correct Answer: d. neither of these (option a has incorrect loop condition, and option b modifies sub instead of points[sub])
109
Two arrays that store related information in corresponding element positions are _______________________ arrays. a. jagged b. parallel c. relative d. rectangular
Correct Answer: b. parallel
109
Assume an array is defined as int[] nums = {2, 3, 4, 5};. Which of the following would display the values in the array in reverse? a. for(int x = 4; x > 0; --x) Write(nums[x]); b. for(int x = 3; x >= 0; --x) Write(nums[x]); c. for(int x = 3; x > 0; --x) Write(nums[x]); d. for(int x = 4; x >= 0; --x) Write(nums[x]);
Correct Answer: b. for(int x = 3; x >= 0; --x) Write(nums[x]);
109
Assume an array is defined as int[] nums = {7, 15, 23, 5};. Which of the following would place the values in the array in descending numeric order? a. Array.Sort(nums); b. Array.Reverse(nums); c. Array.Sort(nums); Array.Reverse(nums); d. Array.Reverse(nums); Array.Sort(nums);
Correct Answer: c. Array.Sort(nums); Array.Reverse(nums);
109
Which of the following traits do the BinarySearch() and Sort() methods have in common? a. Both methods take a single argument that must be an array. b. They both operate only on arrays made up of numeric data. c. The array that each method uses must start in ascending order. d. Both methods belong to the System.Array class.
Correct Answer: d. Both methods belong to the System.Array class.
109
If you use the BinarySearch() method, and the object you seek is not found in the array, _______________________. a. an error message is displayed b. a zero is returned c. the value false is returned d. a negative value is returned
Correct Answer: d. a negative value is returned
109
The BinarySearch() method is inadequate when _______________________. a. array items are in ascending order b. the array holds duplicate values and you want to find them all c. you want to find an exact match for a value d. array items are not numeric
Correct Answer: b. the array holds duplicate values and you want to find them all
109
Which of the following declares an integer array that contains eight rows and five columns? a. int[8, 5] num = new int[ , ]; b. int [8][5] num = new int[]; c. int [ , ] num = new int[5, 8]; d. int [ , ] num = new int[8, 5];
Correct Answer: d. int [ , ] num = new int[8, 5];
109
At most, a class can contain _____________________ method(s). a. 0 b. 1 c. 2 d. any number of
Correct Answer: d. any number of
109
Which of the following is a good reason for creating methods within a program? a. Methods are easily reusable. b. Because all methods must be stored in the same class, they are easy to find. c. The Main() method becomes more detailed. d. All of these are true.
Correct Answer: a. Methods are easily reusable.
109
In C#, a method must include all of the following except _____________________. a. a return type b. an access modifier c. curly braces d. a closing curly brace
Correct Answer: b. an access modifier
109
If a method does not contain a declared accessibility, then the method is _____________________. a. illegal b. nonstatic c. private d. void
Correct Answer: c. private
109
Every method declaration must contain _____________________. a. a statement of purpose b. a return type c. the static modifier d. declared accessibility
Correct Answer: b. a return type
109
If you want to create a method that other methods in other classes can access without limitations, you declare the method to be _____________________. a. unlimited b. shared c. public d. unrestricted
Correct Answer: c. public
109
If you use the keyword modifier static in a method header, you indicate that the method _____________________. a. cannot be copied b. is called without an object reference c. cannot require parameters d. can be called only once
Correct Answer: b. is called without an object reference
109
A method’s type is also its _____________________. a. return type b. accessibility c. parameter type d. scope
Correct Answer: a. return type
109
When you use a method, you do not need to know how it operates internally. This feature is called _____________________. a. scope management b. selective ignorance c. implementation hiding d. privacy
Correct Answer: c. implementation hiding
109
When you write the method declaration for a method that can receive a parameter, you need to include all of the following items except _____________________. a. a pair of parentheses b. the type of the parameter c. a local name for the parameter d. an initial value for the parameter
Correct Answer: d. an initial value for the parameter
109
Suppose you have declared a variable as int myAge = 21;. Which of the following is a legal call to a method with the following declaration? private static void AMethod(int num) a. AMethod(int 55); b. AMethod(myAge); c. AMethod(int myAge); d. AMethod();
Correct Answer: b. AMethod(myAge);
109
Suppose you have declared a method named private static void CalculatePay(double rate) When a method calls the CalculatePay() method, the calling method _____________________. a. must contain a declared double named rate b. might contain a declared double named rate c. cannot contain a declared double named rate d. cannot contain any declared double variables
Correct Answer: b. might contain a declared double named rate
109
In the method call PrintTheData(double salary);, salary is the _____________________ parameter. a. actual b. formal c. proposed d. preferred
Correct Answer: a. actual
109
A program contains the method call PrintTheData(salary);. In the method definition, the name of the formal parameter must be _____________________. a. salary b. any legal identifier other than salary c. any legal identifier d. omitted
Correct Answer: c. any legal identifier
109
What is a correct declaration for a method that receives two double arguments, calculates and displays the difference between them, and returns nothing? a. private static void CalcDifference(double price1, price2) b. private static void CalcDifference(double price1, double price2) c. Both of these are correct. d. None of these are correct.
Correct Answer: b. private static void CalcDifference(double price1, double price2)
109
What is a correct declaration for a method that receives two double arguments and sums them but does not return anything? a. private static void CalcSum(double firstValue, double secondValue) b. private static void CalcSum(double price1, double price2) c. Both of these are correct. d. None of these are correct.
Correct Answer: c. Both of these are correct.
109
A method is declared as private static double CalcPay(int hoursWorked) Suppose you write a Main() method in the same class and that it contains the declarations int hours = 35; double pay; Which of the following represents a correct way to call the CalcPay() method from the Main() method? a. hours = CalcPay(); b. hours = Main.CalcPay(); c. pay = CalcPay(hoursWorked); d. pay = CalcPay(hours);
Correct Answer: d. pay = CalcPay(hours);
109
Suppose the value of IsRateOK() is true, and the value of IsQuantityOK() is false. When you evaluate the expression IsRateOK() || IsQuantityOK(), which of the following is true? a. Only the method IsRateOK() executes. b. Only the method IsQuantityOK() executes. c. Both methods execute. d. Neither method executes.
Correct Answer: a. Only the method IsRateOK() executes.
109
Suppose the value of IsRateOK() is true, and the value of IsQuantityOK() is false. When you evaluate the expression IsRateOK() && IsQuantityOK(), which of the following is true? a. Only the method IsRateOK() executes. b. Only the method IsQuantityOK() executes. c. Both methods execute. d. Neither method executes.
Correct Answer: b. Only the method IsQuantityOK() executes.
110
When an array is passed to a method, the method has access to the array’s memory address. This means an array is passed by _____________________. a. reference b. value c. alias d. orientation
Correct Answer: a. reference
110
In Object-Oriented Programming, the ability to create methods that act appropriately depending on the context is called? Instance Encapsulation Inheritance Polymorphism
Correct Answer: Polymorphism
111
In using System;, what is System referring to? Variable Class Method Namespace
Correct Answer: Namespace
112
Which of the following is NOT a valid C# identifier? _order a a1 this (Reserved keyword)
Correct Answer: this
113
Which of the following pairs is an example of a class and an object, in that order? CSUF and University Cup and Glass Car and Vehicle Animal and Bear
Correct Answer: Animal and Bear
114
What is NOT considered a keyword by the C# language? Static Global Implicit Catch
Correct Answer: Global
115
Assume you have a variable declared as int var1 = 5; What is the value of 27 % var1? 4 5 0 2
Correct Answer: 2
116
What is the value of the expression 3 + 4 * 2? 14 10 11 (Multiplication before addition) 5
Correct Answer: 11
117
What is the value of 5 >= 3? True False 0 1
Correct Answer: True
118
Question 9: In C#, you use the ____ data type to hold a series of characters. int sbyte string char
Correct Answer: string
119
Which expression is equivalent to x || y && w || z? (x || y) && (w || z) Two of these x || (y && w) || z x && y || w && z
Correct Answer: x || (y && w) || z
120
What is the value of the variable counter after these statements? double percent = 0.54; bool valid = true; int counter = 1; if ((percent > 0.50) && (valid == true)) { counter += 2; if (valid == true) counter++; } 7 3 2 4
Correct Answer: 4
121
Which value of x would make this condition true: (x >= 5) && (x <= 6)? x = 7 x = 5.001 x = 5 Both B and C
Correct Answer: x = 5.001 and x = 5
122
If orderTotal = 50 and quantity = 10, what is the discount after executing this code? if (quantity == 1 || quantity == 2) discount = 0; else if (quantity >= 3 && quantity < 10) discount = orderTotal * 0.1; else if (quantity > 10 && quantity <= 25) discount = orderTotal * 0.2; else discount = orderTotal * 0.3; 10 0 5 15
Correct Answer: 15
123
C# supports a ____ statement that cycles through every array element without using a subscript. While Foreach Do-while For
Correct Answer: Foreach
124
Which access modifier limits method access to the containing class and derived classes? None of the above Private Protected Internal
Correct Answer: Protected