Computer Programming Chapters 4-6 (Test 2)
A ____ expression has a value of either true or false
Boolean
By default, the open dialog box displays the contents of the user's Documents directory. How can you specify another directory to be initially displayed?
By storing its path in the InitialDirectory property
What kind of code should be placed in the Load event?
Code that performs setup operations
A _____ is commonly used to control the number of times that a loop iterates.
Counter Variable
A _____ structure executes a set of statements only under certain circumstances
Decision
The ____ section of a switch statement is branched to if none of the case values match the test expression
Default
A _____ structure tests a condition and then takes one path if the condition is true or another path if the condition is false
Dual- alternative decision
The ____ operator takes a Boolean expression as its operand and reverses its logical value.
!
A compound Boolean expression created with the ____ operator is true only if both of its subexpressions are true.
&&
How do you add items to the ListBox using the properties window?
(1) Select the ListBox control in the Designer window. (2) In the Properties window, the setting for the Items property is displayed as (Collection). When you select the Items property, an ellipsis button ( ) appears. (3) Click the ellipsis button. The String Collection Editor dialog box appears. (4) Type the values that are to appear in the ListBox into the String Collection Editor dialog box. Type each value on a separate line by pressing the Enter key after each entry. (5) When you have entered all the values, click the OK button.
What are the two arguments that you pass to a TryParse method?
(1) the string that you want to convert, and (2) the name of the variable in which you want to store the converted value.
A ListBox's index numbering starts at _____
0
What is meant by the term "conditionally executed"?
A conditionally executed statement is performed only when a certain condition is true.
You need to test a condition and then execute one set of statements if the condition is true. If the condition is false, you need to execute a different set of statements. What structure will you use?
A dual alternative decision structure (the if-else statement)
What is a flag and how does it work?
A flag is a variable that signals when some condition exists in the program. When the flag variable is set to false, it indicates the condition does not exist. When the flag variable is set to true, it means the condition does exist.
What is contained in the body of the loop?
A statement or series of statements in a loop that are executed if the Boolean expression is true.
What is a variable that is used to accumulate a total called?
An accumulator
Why is the system time the preferred seed value for a Random object?
Because the system time is a unique value that changes every hundredth of a second.
If the ListBox is empty, the Items.Count property equals -1.
False
T/F A single-alternative structure tests a condition and then takes one path if the condition is true or another path if the condition is false.
False
T/F If an item is not selected in a ListBox, the control's SelectedIndex property will not be set to 0.
False
T/F The TryParse methods throw an exception if the string argument cannot be converted.
False
T/F The test expression in a switch statement can be a double or a decimal value.
False
T/F To store items in a ListBox, you add them to the control's Text property.
False
T/F You can write any program using only sequence structures.
False
The Load event takes place after the form is displayed on the screen.
False
The numbers that are generated by the Random class are truly random.
False
The term "read file" is used to describe a file that data is read from.
False
The while loop always performs at least one iteration, even if its Boolean expression is false to begin with.
False
ListBox controls have an ________ method that erases all the items in the Items property.
Items.Clear
A ____ object is an object that is associated with a specific file and provides a way for the program to work with that file.
File
Files on a disk are identified by a ____.
Filename
When the user selects a file with the OPEN dialog box, the file's path and filename are stored in the controls ____ property.
Filename
A ___________ is a Boolean variable that signals when some condition exists in the program.
Flag
A compound Boolean expression created with the _____ operator is true if either of its subexpressions are true.
I I
You use a(n) __________ statement to write a single alternative decision structure.
If
You use a(n) _____ statement to write a dual alternative decision structure.
If-else
The term ____ is used to describe a file that data is read from.
Input file
When you run an application, the application's form is loaded into memory and an event known as the ____ event takes place.
Load
&&, II and ! are _____ operators
Logical
A ____ decision structure is written inside another decision structure
Nested
Once you have created a Random object, you can call its ______ method to get a random integer number.
Next
The term _____ is used to describe a file that data is written to.
Output file
A(n)______ loop tests its condition BEFORE performing an iteration.
Pretest
If several __________ controls exist in a GroupBox, only one of them may be selected at a time.
RadioButton
When a program works with an input file, a special value known as a _____ is internally maintained for that file and marks the location of the next item that will be read from the file.
Read position
The symbols > < and == are all _____ operators
Relational
The ____ control displays a standard Windows Save As dialog box.
SaveFileDialog
You can use the ____ property to determine whether an item is selected in a ListBox.
SelectedIndex
The _____ property holds the item that is selected in a ListBox control.
SelectedItem
What are filename extensions? What do they indicate about a file?
Sequences of characters that appear at the end of a filename preceded by a period; they indicate the type of data stored in the file
When you work with a ____ file you access data from the beginning of the file to the end of the file.
Sequential access
A _____ structure provides one alternative path of execution
Single- alternative path
You use the ____ statement to create a multiple alternative decision structure.
Switch
A ____ file contains data that has been encoded as text, using a scheme such as Unicode
Text
Briefly describe how the && operator works.
The && operator connects two Boolean expressions into one compound expression. Both subexpressions must be true for the compound expression to be true.
When determining whether a number in inside a range, which logical operator is best to use?
The && operator.
When an input file is opened, what is its read position initially set to?
The first item in the file
Briefly describe how the I I operator works.
The || operator connects two Boolean expressions into one compound expression. One or both subexpressions must be true for the compound expression to be true. It is only necessary for one of the subexpressions to be true, and it does not matter which.
How do you determine in code whether a RadioButton control or a CheckBox control is selected?
They have a Checked property that determines whether the control is selected or deselected. The Checked property is a Boolean property, which means that it may be set to either True or False. When the Checked property is set to True, the control is selected, and when the Checked property is set to False, the control is deselected.
As items are read from the file, the read position moves forward, toward the file.
True
T/F A compound Boolean expression created with the && operator is true only when both subexpressions are true
True
T/F A decision structure can be nested inside another decision structure
True
T/F Multiple CheckBox controls in the same GroupBox can be selected at the same time.
True
T/F The if-else statement is a dual-alternative decision structure
True
The while loop is known as the pretest loop, which means it tests its condition BEFORE performing an operation.
True
To append data to an existing file, you open it with the File.AppendText method.
True
To increment a variables means to increase its value and to decrement a variable means to decrease its value.
True
When a variable is declared in the initialization expression of a for loop, the scope of the variable is limited to the loop.
True
The ____ family of methods can be used to convert a string to a specific data type without throwing an exception.
TryParse
How can you read the selected item from a ListBox while preventing an exception from occurring if no item is selected?
When the user selects an item in a ListBox, the item's index is stored in the ListBox's SelectedIndex property. If no item is selected in the ListBox, the SelectedIndex property is set to -1. You can examine the SelectedIndex property to make sure that an item is selected in a ListBox before you try to get the value of the SelectedItem property.
How can you read all the items in a file without knowing how many times the file contains?
You can write a loop that iterates as long as the EndOfStream property is false
How many iterations will occur if the test expression of a for loop is false to begin with?
Zero, the loop terminates as soon as it begins
Write a programming statement that uses postfix mode to increment a variable named count.
count++;
When generating random numbers, the _____ value is used in the calculation that returns the next random number in the series.
seed