C. Sharp
C. Sharp
Multiple Choice
1. In general terms, a program that is broken into smaller units of code, such as methods, is known as
a(n) __________.
a. object-oriented program
b. modularized program
c. procedural program
d. method-driven program
2. Writing the code to perform a task once and then reusing it each time you need to
a. code reuse
c. method recycling
d. code reprocessing
3. When you call a(n) __________, it simply executes the statements it contains and
then terminates.
a. intrinsic method
b. empty method
c. logical method
d. void method
4. The __________, which appears at the beginning of a method definition, lists several
a. method title
b. method description
c. method header
d. method declaration
a. method body
b. method designation
c. method code
d. method classification
6. The __________ is the memory address that is saved by the system when a method is
called and is the location to which the system should return after a method ends.
a. calling address
b. method address
c. return point
a. prototyping
b. method modeling
c. algorithm division
d. top–down design
8. Pieces of data that are sent into a method are known as __________.
a. arguments
b. references
c. method variables
d. data entries
9. A(n) __________ is a special variable that receives an argument when a method is called.
a. reference variable
b. argument variable
c. parameter variable
d. method variable
a. named argument
b. special argument
c. constant argument
d. literal argument
11. When a(n)__________ is provided for a parameter, it becomes possible to call the
a. local argument
b. empty argument
c. default argument
d. expressional argument
12. When an argument is __________, only a copy of the argument’s value is passed into
a. a named constant
b. passed by association
c. passed by reference
d. passed by value
13. When you want a method to be able to change the value of a variable that is passed
a. passed by reference
b. a local variable
c. passed by value
d. a named constant
14. A __________ a special type of parameter variable that is useful for establishing
a. communication variable
b. reference parameter
c. method parameter
d. global variable
15. A(n) __________ can have an uninitialized value passed into it, but it must be set to
a. input parameter
b. reference parameter
c. output parameter
d. default parameter
16. A method’s __________ is the type of value that the method returns.
a. data type
b. return type
c. value type
d. method type
True or False
1. Dividing a large problem into several smaller problems that are easily solved is
3. If a method belongs to a class, then you must write a method’s definition inside
4. The contents of variables and the values of expressions cannot be passed as arguments. False
5. You do not have to write the data type for each parameter variable that is declared
in a parameter list if they are all of the same data type. False
Short answer
1. What do you call a method that executes the statements it contains and then returns
value-returning method
2. What is the standard naming convention used among C# programmers for method
names? Why?
Pascal Case (because it makes the method name different from fields and variable names)
parameterName.value
Output: the value of an argument need not to be set before passing it to output parameter.
Value of the output parameter must be set to some value before completing the execution.
Output parameter must be declared by using the keyword out before data type of parameter
variable.
Reference: The value of an argument must be set before passing it to reference parameter
Value of the reference parameter should not be set to some value before completing the
execution
Similar: It includes set of statements that does a specific task. Whenever the method needs to be
executed,
8. Can Boolean methods be used to modularize input validation? Why or why not?
Yes they can be used if a form contains many Textbox controls, then input validation needs nested
and multiple if statements
Chapter 7
Multiple Choice
1. The memory that is allocated for a __________ variable is the actual location that
a. reference type
b. general type
c. value type
d. framework type
b. resource variable
c. object variable
d. component variable
3. When you want to work with an object, you use a variable that holds a special value
a. union
b. reference
c. object linker
d. data coupling
4. The __________ creates an object in memory and returns a reference to that object.
a. = operator
b. object allocator
c. reference variable
d. new operator
5. A(n) __________ is an object that can hold a group of values that are all of the same
data type.
a. array
b. collection
c. container
d. set
6. The __________ indicates the number of values that the array should be able to
hold.
a. allocation limit
b. size declarator
c. data type
d. compiler
a. elements
b. sectors
c. pages
d. blocks
a. element identifier
b. subscript
c. index
d. sequencer
9. When you create an array, you can optionally initialize it with a group of values
b. initialization list
c. defined set
d. value list
10. In C#, all arrays have a __________ that is set to the number of elements in the
array.
a. Limit property
b. Size property
c. Length property
d. Maximum property
11. A(n) __________ occurs when a loop iterates one time too many or one time too
few.
a. general error
b. logic error
d. off-by-one error
12. C# provides a special loop that, in many circumstances, simplifies array processing.
a. for loop
b. foreach loop
c. while loop
d. do-while loop
13. The foreach loop is designed to work with a temporary, read-only variable that is
a. element variable
b. loop variable
c. index variable
d. iteration variable
14. __________ is a process that periodically runs, removing all unreferenced objects
from memory.
a. Systematic reallocation
b. Memory cleanup
c. Garbage collection
d. Object maintenance
15. Various techniques known as __________ have been developed to locate a specific
a. seek functions
b. request methods
c. traversal procedures
d. search algorithms
16. The __________ uses a loop to step through an array, starting with the first element,
b. top-down method
b. reference copy
c. double reference
d. parallel copy
18. The __________ is a clever algorithm that is much more efficient than the sequential
search.
a. linear search
b. bubble sort
c. binary search
d. selection sort
19. A __________ is similar to a two-dimensional array, but the rows can have different
numbers of columns.
a. one-dimensional array
b. columnar array
c. jagged array
20. The .NET Framework provides a class named __________, which can be used for
a. Matrix
b. Database
c. Container
d. List
True or False
1. When you are working with a value type, you are using a variable that holds a piece
of data. TRUE
3. Individual variables are well suited for storing and processing lists of data. FALSE
7. The subscript of the last element will always be one less than the array’s Length
property. TRUE
8. You use the == operator to compare two array reference variables and determine
9. A jagged array is similar to a two-dimensional array, but the rows in a jagged array
10. When you create a List object, you do not have to know the number of items that
Short answer
1. How much memory is allocated by the compiler when you declare a value type
variable?
The compiler sets aside, or allocates, a chunk of memory that is big enough for that variable.
3. What two steps are typically required for creating a reference type object?
4. Are variables well suited for processing lists of data? Why or why not?
No. Because variables hold only a single value, they can be cumbersome in programs that process lists
of data.
When a loop iterates one time too many or one time too few.
7. How do you keep track of elements that contain data in a partially filled array?
A partially filled array is normally used with an accompanying integer variable that holds the number
of items that are actually stored in the array.
8. Briefly describe the selection sort algorithm.
The smallest value in the array is located and moved to element 0. Then the next smallest value is
located and moved to element 1. This process continues until all of the elements have been placed in
their proper order.
9. How is the binary search more efficient that the sequential search algorithm?
The portion of the array being searched is divided in half each time the loop fails to located the search
value.
1. When you create a List object, you do not have to know the number of items that you intend
to store in it.
2. A list object automatically expands as items are added to it.
3. In addiction to adding items to a List, you can removed items as well.
4. A list object automatically shrinks as items are removed from it.
Chapter 8
Multiple Choice
a. strings
b. enumerators
c. tokens
d. character literals
2. The char data type provides the __________ for converting the case of a character.
a. character
b. inner string
c. substring
d. thread
5. When you want to know the position of the substring, you can use one of the
6. The __________ of a string object can be used to retrieve a specific set of characters from a string.
a. Substring method
b. IndexOf method
a. Leading spaces
b. Primary spaces
c. Starting spaces
d. Empty spaces
a. Blank spaces
b. Secondary spaces
c. Ending spaces
d. Trailing spaces
b. elements
c. characters
d. tokens
a. partition
b. literal
c. delimiter
d. symbol
a. extracting
b. tokenizing
c. delimiting
d. parsing
12. The __________ file format is commonly used to export spreadsheet data to a text file.
13. A __________ is a data type you can create that contains one or more variables
known as fields.
a. structure
b. collection
c. volume
d. list
14. Before you can use a structure to store data, you must create a(n) __________ of the
structure in memory.
a. copy
b. instance
c. declaration
d. reference
15. When the items in two data structures are related by their indexes, it is said that a
a. binary union
b. parallel relationship
c. unilateral bond
d. virtual connection
16. When you create a(n) __________, you specify a set of symbolic values that belong
a. Literals
b. Enumerators
c. Constants
d. Tokens
a. ImageList control
b. GroupBox control
c. PictureBox control
d. ComboBox control
True or False
1. You cannot store a string in a variable of the char data type TRUE
2. C# allows you to access the individual characters in a string using subscript notation. TRUE
3. When you call a string object’s Split method, the method divides the string into
5. Before you can use the structure to store data, you must create an instance of the
9. An enum declaration can only appear inside the application’s namespace. FALSE
10. The integer values that you assign to enumerators do not have to be unique. TRUE
11. You can compare enumerators and enum variables with relational operators. TRUE
12. ImageList controls are designed to store small images such as icons or thumbnails. TRUE
Short answer
5. What characters are used as delimiters when you pass null as an argument to the Split method of
a string object?
Whitespace
demonstrates how you would create a List that can hold Fruit objects.?
8. Can enumerators be used in a loop to step through the elements of an array? Why or why not?
Yes. Because enumerators represent integer values, they can be used in a loop to step through the
elements of an array.
9. Why should you use the new operator when creating instances of a structure?
You should use the new operator when creating instances of a structure because the new operator
initializes the fields to the default value of 0 or null. An instance with uninitialized fields will result in a
compiler error, so it is a good idea to use the new operator to avoid causing this error.
10. What is the result if the value of the ImageSize property does not match the size of the images that
are stored in the ImageList control?