Chapter 4 Complete Test Bank Making Decisions - Test Bank | Visual C# 5e by Tony Gaddis. DOCX document preview.
Starting Out with Visual C#, 5e (Tony Gaddis)
Chapter 4 Making Decisions
TRUE/FALSE
1. The sequence structure is often used in programming because it can handle every type of task.
2. If you are writing an if statement that has only one conditionally executed statement, you must enclose the conditionally executed statement in curly braces.
3. The equality operator is written like this: = (with only one equals sign).
4. It is often true that both sets of conditionally executed statements in an if-else statement are executed.
5. Any if-else-if statement can be coded, alternatively, as a nested if-else statement.
6. In order for an && expression to be true, only the expression on one side of the && operator needs to be true.
7. If the expression on the left side of the || operator is true, the expression on the right side is not checked.
8. The == operator cannot be used to compare string expressions.
9. You should use try-catch statements primarily for exceptions that are beyond your control.
10. Because the TryParse methods return either true or false, they are commonly called as the Boolean expression in an if statement.
11. Check boxes are similar to radio buttons in that they are both mutully exclusive.
12. A switch statement's test expression can be any data type.
13. When displaying an item from a ListBox, you have to call the SelectedItem property's ToString method to retrieve the value as a string.
14. RadioButton controls are grouped according to the container in which they are placed.
15. A well-designed program should validate the contents of multiple TextBoxes in a single statement.
16. When a program compares characters, it actually compares the numeric Unicode values of the characters.
17. Variables of the double data type are commonly used as flags.
18. The ! operator has a higher precedence than the relational operators such as < or >.
19. If an expression A is true, prefixing it with the ! operator (!A) causes the combined expression to become false.
20. In a flowchart, the diamond symbol indicates some condition that must be tested.
MULTIPLE CHOICE
1. A __________ appears as a small box with some accompanying text.
a. | list box | c. | check box |
b. | link | d. | radio button |
2. When a RadioButton or a CheckBox control's Checked property changes, a __________ event happens for that control.
a. | SelectionChanged | c. | CheckChanged |
b. | Checked | d. | Click |
3. When you want to create a check box on a form, you use the __________ control which is found in the Common Controls section of the Toolbox.
a. | CheckBox | b. | RadioButton | c. | ListBox | d. | LinkLabel |
4. The __________ statement is a multiple-alternative decision structure which allows you to test the value of a variable or an expression and then use that value to determine which statement or set of statements to execute.
a. | switch | b. | if | c. | try-catch | d. | else |
5. In Visual C# you use the __________ control to create a list box on an application's form.
a. | ListView | c. | CheckedListBox |
b. | MaskedTextBox | d. | ListBox |
6. Once you create a ListBox control, you add items you wish to display to its __________ property.
a. | Display | b. | Text | c. | Items | d. | Values |
7. When the user selects an item in a ListBox, the item is stored in the ListBox's __________ property.
a. | Checked | c. | DataSelection |
b. | SelectedValue | d. | SelectedItem |
8. Each item in a ListBox has a(n) __________ which is an integer that identifies the item's position in the ListBox.
a. | index | c. | unique identifier |
b. | list number | d. | table key |
9. When the user selects an item in a ListBox, the item's index is stored in the ListBox's __________ property.
a. | DataValue | c. | Index |
b. | SelectedIndex | d. | ValueIndex |
10. If no item is selected in a ListBox, what value is in the SelectedIndex property?
a. | false | b. | true | c. | 0 | d. | -1 |
11. A(n) __________ structure is a logical design that controls the order in which a set of statements execute.
a. | elementary | b. | logic | c. | control | d. | sequence |
12. A(n) __________ structure is a set of statements that execute in the order in which they appear.
a. | ordered | b. | command | c. | control | d. | sequence |
13. A(n) __________ structure can execute a set of statements only under certain conditions.
a. | sequence | b. | decision | c. | circumstantial | d. | event |
14. An action that is __________ occurs only when a certain condition is true.
a. | conditionally executed | c. | interactively driven |
b. | logically executed | d. | truth bound |
15. A(n) __________ decision structure provides only one path of execution.
a. | alternative path | c. | single path |
b. | single-alternative | d. | ordered path |
16. A __________ expression is an expression that can be evaluated as either true or false.
a. | binary | b. | double | c. | Boolean | d. | classical |
17. A(n) __________ compares the values of two expressions.
a. | relational operator | c. | associative operator |
b. | bitwise assessment | d. | comparative structure |
18. Which of the following expressions determines whether the value of the variable named length is greater than or equal to the value of the variable named width?
a. | length < width |
b. | width <= length |
c. | length > width |
d. | length >= width |
19. Which of the following expressions determines if the value of the variable named balance is equal to 0?
a. | 0 = balance | c. | balance = 0 |
b. | balance == 0 | d. | balance <= 0 |
20. A(n) __________ statement has two parts: an if clause and an else clause.
a. | logic | b. | if-else | c. | Boolean | d. | else-if |
21. The __________ structure has two possible paths of execution. One path is taken if the Boolean expression is true and the other path is taken if the Boolean expression is false.
a. | dual-alternative decision | c. | multi-decision |
b. | comparative | d. | branching |
22. The C# language provides a set of operators known as __________ operators which you can use to create complex Boolean expressions.
a. | Boolean | c. | logical |
b. | relational | d. | expressional |
23. The __________ operator is the logical AND operator which takes two Boolean expressions as operands and creates a compound Boolean expression that is true only when both subexpressions are true.
a. | ! | b. | <> | c. | && | d. | || |
24. The __________ operator is the logical OR operator which takes two Boolean expressions as operands and creates a compound Boolean expression that is true when either of the subexpressions is true.
a. | ! | b. | <> | c. | && | d. | || |
25. The __________ operator is the logical NOT operator which is a unary operator that takes a Boolean expression as its operand and reverses its logical value.
a. | ! | b. | <> | c. | && | d. | || |
26. Both the && and || operators perform __________ in which CPU time is saved by not checking the expression on the right side of the operator depending on the value of the expression on the left side of the operator.
a. | logical optimization | c. | cycle-branching |
b. | short-circuit evaluation | d. | single-stage execution |
27. The expression given below will determine if the value in A is outside a range, if XX is replaced by which logical operator?
(A < 1) XX (A > 10)
a. | && | b. | ! | c. | || | d. | >= |
28. The expression given below will determine if the value in A is inside a range, if XX is replaced by which logical operator?
(A < 1) XX (A > 10)
a. | && | b. | ! | c. | || | d. | >= |
29. You can use the __________ logical operator to compare two strings.
a. | && | b. | == | c. | || | d. | ! |
30. The __________ method can be used to determine whether one string is greater than or less than another string.
a. | String.Equals | c. | String.IsGreater |
b. | String.Compare | d. | String.String |
31. The __________ method can determine whether a string contains a value that can be converted to a specific data type before it is converted to that data type.
a. | Parse | c. | Peek |
b. | TryParse | d. | String.Compare |
32. The __________ method can be used to convert a string to an integer.
a. | Try.Parse.int | c. | int.TryParse |
b. | int.Parse | d. | TryParse.int |
33. To convert a string to a double, use the __________ method.
a. | String.ToDouble | c. | Try.ParseDouble |
b. | double.TryParse | d. | ToString |
34. A string can be converted to a decimal with the __________ method.
a. | decimal.ParseString | c. | Try.Parse(decimal) |
b. | decimal.ToString | d. | decimal.TryParse |
35. The __________ keyword is required when specifying a variable as an output argument.
a. | in | b. | out | c. | extern | d. | static |
36. A(n) __________ is a variable that is passed as an argument to a method and, when the method is finished, a value is stored in the variable.
a. | output variable | c. | parameter variable |
b. | result variable | d. | method variable |
37. The process of checking input for errors before it is processed is called __________.
a. | parsing | c. | pre-rendering |
b. | input validation | d. | data authentication |
38. __________ are useful when you want the user to select one choice from several possible choices.
a. | Radio buttons | c. | Buttons |
b. | Check boxes | d. | Text boxes |
39. __________ selection works by automatically deselecting any other items in the same group when a single item is selected.
a. | Multiple | c. | Mutually exclusive |
b. | Mutually inclusive | d. | Monographic |
40. Radio button controls have a __________ property that determines whether the control is selected or deselected.
a. | Selected | b. | Checked | c. | Pushed | d. | Active |