(TCO 4) A car dealership is running a promotion that includes a 25% discount on last year’s models. Which of the following is the appropriate structure to use to determine if a given car fits the criteria for the discount?
Question 2. Question :
(TCO 6) When using the Visual Studio, press _____ to start debugging your program.
Question 3. Question :
(TCO 6) To cause the Visual Studio debugger to halt execution of your program at a particular statement, set a _____ at that statement.
Question 4. Question :
Question 5. Question :
(TCO 4) The symbol && is an example of a C# _____ operator.
Question 6. Question :
Question 7. Question :
Question 8. Question :
(TCO 6) C# code that might create a problem at runtime can be placed in a _____ block. Code to deal with the problem is then placed in a _____ block.
Question 9. Question :
All IF statements contain a conditional expression that evaluates to true or false.
Question 10. Question :
Compile errors and run-time errors mean the same thing.
Question 11. Question :
Question 12. Question :
Question 1. Question :
(TCO 5) When writing a program, if you know exactly how many times statements in a loop should execute, use the _____ structure.
do while
for
goto
while
Instructor Explanation: With the FOR structure, the programmer specifies the number of iterations the loop will perform.
Points Received: 4 of 4
Comments:
Question 2. Question :
(TCO 5) When used within a loop structure, the _____ statement causes execution to jump out of the loop and proceed with subsequent statements in the program.
break
continue
goto
jump
Instructor Explanation: BREAK breaks completely out of the loop whereas CONTINUE transfers control to the loop’s conditional expression.
Points Received: 4 of 4
Comments:
Question 3. Question :
(TCO 5) A block of statements within the body of a FOR loop must be surrounded with _____.
curly braces {}
parentheses ()
square brackets []
None of the above
Instructor Explanation: Although a loop body containing a single statement needs no braces, several statements must be surrounded with curly braces.
Points Received: 4 of 4
Comments:
Question 4. Question :
(TCO 5) What output will this set of statements produce?
int a = 1;
while (a < 1)
{
Console.Write(“{0}\t”, a);
a++;
}
Console.Write(“{0}\t”, a);
An infinite loop
An exception
1
1 1
Instructor Explanation: Because “a” will never be less than 1, the WHILE loop will not execute. The value of “a” will remain 1.
Points Received: 4 of 4
Comments:
Question 5. Question :
(TCO 5) In this code, the inner FOR loop _____.
int i = 1, j = 1;
for (i = 1; i < 4; i++)
{
for (j = 1; j < 4; j++)
{
Console.Write(“{0}{1} “, i, j);
}
}
contains a syntax error
is nested
is like a blue sky
is like a light
Instructor Explanation: The inner FOR is nested inside the outer FOR, so for every execution of the outer FOR, the inner FOR will execute three times.
Points Received: 4 of 4
Comments:
Question 6. Question :
(TCO 5) Your program keeps asking for last names from the user until he/she enters “####.” In this context, the “####” is used as a(n) _____.
accumulator
counter
sentinel value
test value
Instructor Explanation: A sentinel value is a dummy variable not used for processing. It’s used to signify when a loop should stop executing.
Points Received: 4 of 4
Comments:
Question 7. Question :
GOTO statements should be avoided.
True False
Instructor Explanation:
Yes, since they are often result in unstructured and confusing code. Break and Continue is a much better choice.
Note that GOTO usually works with a Label.
Points Received: 4 of 4
Comments:
Question 8. Question :
A walkthrough is a form of software peer review the programmer leads members of the development team through the software code, and the participants ask questions and make comments about possible errors, problems of not adhering to development standards, and other problems.
True False
Points Received: 4 of 4
Comments:
Question 9. Question :
Accumulators and counters mean the same thing.
True False
Points Received: 4 of 4
Comments:
Question 10. Question :
Nesting or indenting multiple programming loops is a good coding practice.
True False
Points Received: 4 of 4
Comments:
Question 11. Question :
The For Loop is used when the user wishes to stop the Loop from executing, and is used when the number of Loop Executions is unknown.
True False
Points Received: 4 of 4
Comments:
week 4
(TCO 8) Which words belong in the blank to indicate that the method PerformCalcs() returns an integer to the calling method, and that the method has no restrictions on accessibility?
_____ PerformCalcs()
private static int
public static int
private static void
public static void
Comments:
Question 2. Question :
(TCO 7) Which is not a valid name for a method or function?
1mod
mod_1
MyMod
mod1
Comments:
Question 3. Question :
(TCO 8) The following method has _____ input parameter(s) and returns _____ to the calling method.
Public static int GetResult(int value1, double value2)
2, an integer
2, no value
an integer, an integer
1, an integer
Comments:
Question 4. Question :
The following will return a value of type int:
public static int CalcDiff(int price1 , int price2);
True False
Comments:
Question 5. Question :
The following code is correct:
int myInteger = getWidgets(int myWidgets)
True False
Comments:
Question 6. Question :
Overloaded methods must share the same name and the parameters they accept must differ in number and/or data type. They can return different data types.
True False
Comments:
Question 7. Question :
Local variables can only be accessed by the method that declares them. Global variables can be accessed by any method.
True False
Comments:
Question 8. Question :
void means that the method has a return value.
True False
Comments:
Question 9. Question :
In the code below, Math is a Class:
Math.Sum();
True False
Comments:
Question 10. Question :
My mod is a valid method name
True False
Comments:
week 5
(TCO 11) An array is a list of data items that _____.
share the same data type
are all integers
have different faces
the different flavors
Comments:
Question 2. Question :
(TCO 11) Which statement is true about this array declaration?
int [] myArray = {1,4,3,5,6};
It declares a 5 dimensional array.
The size of the array is five.
It sets the element myArray[1] to 1.
It won’t compile due to a syntax error.
Comments:
Question 3. Question :
(TCO 11) What will be the output of this code?
int[] size = {2,3,5,6,4,5};
Array.Sort(size);
foreach (int
val in size)
Console.Write(“{0} “, val);
2 3 5 6 4 5
5 4 6 5 3 2
6 5 5 4 3 2
2 3 4 5 5 6
Comments:
Question 4. Question :
(TCO 11) When a single array element, such as myArray[2], is passed to a method, the method receives _____.
a copy of the array
the starting address of the array
the address of the element
a copy of the value in the element
Comments:
Question 5. Question :
(TCO 12) The size of a(n) _____ must be determined when the program is written, whereas elements of a(n) _____ can be added or deleted at runtime.
array, ArrayList
ArrayList, array
array, Array class
ArrayList, Array class
Comments:
Question 6. Question :
(TCO 12) In your program, myList was declared as an ArrayList. To append the number 7 to the end of myList, write _____.
myList.Add(7);
myList.Append(7);
myList.Insert(7);
myList.Set(7);
Comments:
Question 7. Question :
This is a valid statement:
decimal [] price = new decimal[5];
True False
Comments:
Question 8. Question :
In the following, we can code height[1,1] in a two-dimensional array that will have values
like this (this is partial code): height = { {2.1, 3.2, 6.5, 7.2},
{5.4, 6.7, 3.5, 3.6} };
True False
Comments:
Question 9. Question :
The following is valid code for a one-dimensional array:
int[] size = {2,3,5,6,4,5};
True False
Comments:
Question 10. Question :
ArrayList “Count” property to give the user the current number of integers with a value of ‘1’ in TempArray.
True False
week 6
Question 1. Question : (TCO 9) A(n) _____ is a notification from the _____ that an action has occurred, such as a mouse click or a key press.
event, operating system
console application, operating system
GUI application, event
event, GUI application
Comments:
Question 2. Question : (TCO 9) Although a _____ usually accepts text input from the user, it can also be used to display text.
ComboBox
Label
MessageBox
TextBox
Comments:
Question 3. Question : (TCO 9) The first time a programmer double-clicks on a TextBox object in Design Mode, the TextBox’s default event handler method _____ is added to the code.
Click()
Enter()
Text()
TextChanged()
Comments:
Question 4. Question : (TCO 9) Type _____ to append “New Year’s Day” to an existing list of holidays in the “listHolidays” ListBox object at runtime.
listHolidays.Items.Add(“New Year’s Day”);
listHolidays.Items.Append(“New Year’s Day”);
listHolidays.Add(“New Year’s Day”);
listHolidays.Append(“New Year’s Day”);
Comments:
Question 5. Question : (TCO 9) Which of the following statements will retrieve the selected item of a ComboBox called “cmboWines” and place it in a string variable called “str”?
string str = cmboWines.SelectedItem;
string str = cmboWines.Selection();
string str = cmboWines.Text;
string str = cmboWines.getText();
Comments:
Question 6. Question : A Button is also known as a Form Control.
True
False
Comments:
Question 7. Question : Form controls include Buttons, Needles, Labels, and Textboxes.
True
False
Comments:
Question 8. Question : A Label object is normally used to provide descriptive text or a label for another control.
True
False
Comments:
Question 9. Question : Because it is the most common event associated with a Form, the default event handler method for a Form object is Load().
True
False
Comments:
Question 10. Question : The Text property determines the text that will appear on a Label when the Windows application starts running.
True
False
Comments:
week 7
(TCO 13) Include the _____ namespace in your C# program to enable it to access files and directories.
Student Answer: System.IO
System.Collections.Generic
System
System.Text
Comments:
Question 2. Question :
(TCO 13) Before your C# program attempts to open a file, it should first _____.
Student Answer: call File.Open() to make sure the file can be opened
call File.Exists() to make sure the file exists
call File.Create() to create the file
call File.Close() to close the file in case it was already open
Comments:
Question 3. Question :
(TCO 13) To make your C# program put a new file called “newFile.txt” in the current directory, write _____.
Student Answer: File.Create(“newFile.txt”);
File.CreateNew(“newFile.txt”);
File myFile = new File(“newFile.txt”);
File myFile = new FileStream(“newFile.txt”);
Comments:
Question 4. Question :
(TCO 13) The following C# code will print out _____.
DirectoryInfo dir = new
DirectoryInfo(“.”);
foreach (FileInfo
fil in dir.GetFiles(“*.*”))
Console.WriteLine(fil.Name);
Student Answer: the names of all objects in a program
the names of the methods in a program
the names of all of the variables in a program
the names of all files in the current directory
Comments:
Question 5. Question :
The GetCreationTime() method of the File class returns a string containing the date and time a specified file was created.
True False
Comments:
Question 6. Question :
The StreamReader and StreamWriter classes simplify the process of reading and writing to text files.
True False
Comments:
Question 7. Question :
Because many runtime errors are possible when accessing system resources such as files, it is not important to catch and handle exceptions that may be thrown.
True False
Comments:
Question 8. Question :
The Close() method of the SystemWriter class causes any data in the buffer to be written to the file, and releases any resources associated with the file, such as memory.
True False