Chapter 1 Questions
Decision Table
When an algorithm involves a large number of conditions, a(n) ______ is a compact and readable format for presenting the algorithm.
Namespace
Which of the following C# features should you use to organize code and create globally unique types? a) Assembly b) Namespace c) Class d) Data type
4
Write the following code snippet: How many times will the while loop be executed in this code snippet? a) 0 b) 1 c) 4 d) 5
number1 number2
Write the following code snippet: What output will be displayed after this code snippet is executed? a) number1 b) number2 c) number1 number2 d) number2 number1
26
Write the following code snippet: What will be the value of d after this code snippet is executed? a) 25 b) 26 c) 27 d) 28
Flowchart
A(n) ______ is a graphical representation of an algorithm.
2
Data type You write the following snippet: What is the value of the variable val after this code snippet is executed? a) 1 b) 2 c) 3 d) 4
StackOverflowException
If you don't have a base case in your recursive algorithm, you create an infinite recursion. An infinite recursion will cause your program to throw an exception. Which exception will your program throw in such a case? a) OutOfMemoryException b) StackOverflowException c) DivideByZeroException d)InvalidOperationException
default
In a switch statement, if none of the case statements match the switch expression, then control is transfered to which statement? a) break b) continue c) default d) return
2
On a 32-bit computer, a variable of int data type takes __ bytes of memory
foreach
The ______ loop is the most compact way to iterate through the items in a collection.
Do-while
The ______ loop tests the condition at the bottom of the loop instead of at the top.
Switch
The ______ statement selects for execution a statement list having an associated label that corresponds to the value of an expression.
Ternary
The only operator that takes three arguments is the ______ operator.
1
To access the first element of an array, you use an index of ___.
Infinite Repetitions
You are learning how to develop repetitive algorithms in C#. You write the following method: How many repetitions will the for loop in this code perform? a) 0 b) 4 c) 5 d) Infinite Repetitions
byte
You need to store values ranging from 0 to 255. You also need to make sure that your program minimizes memory use. Which data type should you use to store these values? a) byte b) char c) short d) int
Within a finally block
You need to write code that closes a connection to a database, and you need to make sure this code is always executed regardless of whether an exception is thrown. Where should you write this code? a) Within a try block b) Within a try catch c) Within a finally block d) Within the Main method
Const
______ are data fields of local variables whose value cannot be modified.
Recursion
_______ is a programming technique that causes a method to call itself in order to compute a result.