Multiple Choice Answers

1. (TCOs 1, 6) The user of your program chooses one of nine menu items by entering a number between 1 and 9. The best conditional structure to use to implement each menu procedure is _____.
a series of IF statements
nested IF statements
a loop

2. (TCOs 1, 6) Instructions written in a high-level language such as C# must be translated into machine-level code by a(n) _____.

3. (TCOs 1, 6) Which of the following is a type of C# error that results from invalid use of programming language rules?
Logic error
Syntax error
Runtime error
Syntax error and runtime error

4. (TCOs 2, 3) What will be the output of this statement?
Console.WriteLine(“\”to be or not to be\””);

“to be or not to be”
\”to be or not to be\”
\ to be or not to be \
to be or not to be

5. (TCOs 2, 3) Before you start writing a program, it’s important to first thoroughly _____.
analyze the problem
design the solution
specify the problem
All of the above

6. (TCOs 2, 3) When the correct arithmetic operator precedence rules are applied, what will be the value of the following expression?

5 * 6 / 2 + 1

7. (TCO 4) Which part of this expression will be evaluated first?
if (b <= c && d >= e)

b<= c
c || d
d >= e

8. (TCO 4) If the expression (true OP false) evaluates to “true,” then what logical operator does OP represent?
None of the above

9. (TCO 5) Your program keeps asking for input from the user. If there is more input, the user types “Y” after entering the data. If there is no more input, he/she enters “N.” In this context, “Y” and “N” are used as _____.
integer data types
sentinel values

10. (TCO 5) The _____ structure is a pretest loop, meaning that its conditional expression is tested _____ the statements inside its body execute.
do-while, before
do-while, after
while, before
while, after
11. (TCOs 7, 8) Which is a valid overloaded version of the following method?
floatDetermineResults(float num1, float num2)

floatDetermineResults(double num1, float num2)
float DetermineTheResults(float num1, float num2)
void DetermineResults(float num1, float num2)
double DetermineResults(float num1, float num2)

12. (TCOs 7, 8) Given the following method call, which would be a valid prototype for the calcLetterGrade method?
letterGrade = calcLetterGrade(95.5);

public static intcalcLetterGrade(double val);
public static char calcLetterGrade(double val);
public static double calcLetterGrade(double val);
public static char calcLetterGrade(intval);

13. (TCOs 7, 8) Which is probably a call to a mutator method?
double yards = yds.calcYards();
double yds = GetNoOfYards();
CarpetCalculator plush = new CarpetCalculator();
SetNoOfYards(double yds);

14. (TCOs 9, 10) Because a _____ inherits members from the _____ class, it has the methods Show() and Hide().
Button, Control
Form, Control
RadioButton, ComboBox
TextBox, Form

15. (TCOs 9, 10) A(n) _____ is a notification from the _____ that an action has occurred, such as a mouse click or a key press.
event, GUI application
console application, operating system
GUI application, event
event, operating system

16. (TCOs 9, 10) Often, multiple _____ objects are placed together on a _____ control. The user can only select one of them.
TextBox, ListBox
RadioButton, GroupBox
ListBox, GroupBox
CheckBox, TextBox

17. (TCOs 11, 12) What will be the output of this code?
int[] courses = {2,3,5,6,4,5};
foreach (intval in courses)
Console.Write(“{0} “, val);

2 3 4 5 5 6
5 4 6 5 3 2
6 5 5 4 3 2
2 3 5 6 4 5

18. (TCOs 11, 12) In the following code, “val” represents the _____.
int[] numTVs = {2,3,5,6,4,5};
foreach (intval in numTVs)
Console.Write(“{0} “,val);

array name
memory address of an array element
number of times the loop will execute
value of an array element

19. (TCOs 11, 12) An array is a list of data items that _____.
are all integers
are not indexed
have different names
share the same data type

20. (TCO 13) The following C# statement will print out _____.

the name and path of the current directory
the name of the current directory
the path of the current directory
all of the subdirectories of the current directory

21. (TCO 13) Write _____ to put a new file called “work.doc” in the current directory.
File myFile = new File(“work.doc”);
File myFile = new FileStream(“work.doc”);

22. (TCO 13) The _____ class provides static methods for working with files, whereas the _____ class provides instance methods for similar functionalities.
Directory, DirectoryInfo
File, FileInfo
Directory, FileInfo
File, DirectoryInfo