Ch.7 Arrays And Lists Full Test Bank - Test Bank | Visual C# 5e by Tony Gaddis. DOCX document preview.

Ch.7 Arrays And Lists Full Test Bank

Starting Out with Visual C#, 5e (Tony Gaddis)

Chapter 7 Arrays and Lists

TRUE/FALSE

1. Reference variables can only reference objects.

2. You can store a variety of data types in a single array.

3. An array's size declarator must be a nonnegative integer value.

4. The subscript of the last element in an array is one less than the total number of elements in the array.

5. The first element in an array is assigned subscript 1, the second element is assigned subscript 2, and so on.

6. The default value of a string array's elements is null.

7. An array's Length property is read-only so you cannot change its value by trying to assign a new value to Length.

8. Because the foreach loop automatically knows the number of elements in an array, you do not have to use a counter variable to control its iterations.

9. When processing the contents of an array, the foreach loop does not provide a variable that can be used as an array subscript.

10. To write the contents of an array to a file, open the file and use a loop to step through each array element, writing it to the file. Then close the file.

11. When reading the contents of a file into an array, your loop must always iterate until the array is full.

12. Arrays are always passed by value when passed as method arguments.

13. When you use either the ref or out keywords before an array parameter, the receiving method does not automatically make a local copy of the array.

14. You can use the == operator to compare two array reference variables and determine whether the array contents are equal.

15. If you want to make a separate copy of an array you must create the second array in memory and then copy the individual elements of the first array to the second. This is known as a deep copy.

16. A partially filled array is normally accompanied by an integer variable that indicates the number of items actually stored in the array.

17. A search algorithm is a technique for scanning through an array and rearranging its contents in some specific order.

18. The primary advantage of the binary search algorithm is simplicity but its primary disadvantage, however, is inefficiency.

19. To access a single element in a two-dimensional array you must use two subscripts.

20. Unlike a one-dimensional array, you cannot provide an initialization list for a two-dimensional array.

21. To access an item that is stored in a particular row and column in a jagged array, you enclose the row and column subscripts in their own pair of brackets.

22. You can optionally initialize a List object when you declare it.

23. Each item stored in a List has a corresponding index.

24. An exception will occur if a List index is less than 0 or greater than the List's Count property minus 1.

25. The only requirement for using a binary search is that the values in the array must be sorted in ascending or descending order.

26. To sum all the elements of a two-dimensional array, you can use a pair of nested if statements to add the contents of each element to the accumulator.

27. It is necessary to use reference parameters in any method that must be able to change the values of the items passed to it as arguments.

28. The ImageList control allows you to store a collection of images.

29. All of the images stored in an ImageList control must be the same size but there is no size limit (images can be as big or small as desired) and you can store images in different formats, such as .bmp and .jpg.

30. The default size of the ImageSize property of the ImageList control is 256,256.

MULTIPLE CHOICE

1. A(n) __________ is a special value that links a variable to an object.

a.

linker

b.

reference

c.

operator

d.

delimiter

2. The __________ creates an object in memory and returns a reference to that object.

a.

.NET framework

c.

= operator

b.

new operator

d.

% operator

3. Which of the following statements correctly declares a reference variable named values that can be used to reference an array of int?

a.

int values[];

c.

int[] values;

b.

values[int];

d.

int [values];

4. Which of the following assignment statements associates an int array that can hold twelve integers with a reference variable named scores?

a.

scores = new int[12];

c.

int scores[12];

b.

int[12] = new scores;

d.

new int scores[12];

5. Which of the following statements is not a valid array declaration?

a.

double[] parsecs = new double[10];

b.

decimal[] sales = new decimal[24.5m];

c.

string[] cities = new decimal[50];

d.

int[] quarters = new int[4];

6. Which of the following statements assigns the value 40 to the first element in an array of integers named values?

a.

values[-1] = 40;

c.

values[null] = 40;

b.

values[0] = 40;

d.

values[1] = 40;

7. Which of the following statements correctly initializes an int array named quarters with the values 1, 2, 3, and 4?

a.

const int SIZE = 4;

int[] quarters = new int[SIZE] {1, 2, 3, 4};

b.

int[] quarters = new int[] {1, 2, 3, 4};

c.

int[] quarters = {1, 2, 3, 4};

d.

All of these statements are correct.

8. Each element in an array is identified by a unique number known as a(n) __________.

a.

subscript

b.

identifier

c.

delimiter

d.

vector

9. When you create a numeric array in C#, what default value it assigned to its elements?

a.

null

b.

0

c.

255

d.

-1

10. Given the following code sample, when the loop is finished stepping through the values array, what value will be stored in values[0]?

const int SIZE = 10;

int[] values = new int[SIZE];

for (int index = 0; index < SIZE; index++)

{

values[index] = index + 1;

}

a.

10

b.

11

c.

0

d.

1

11. In C# all arrays have a(n) __________ that equals the number of elements in the array.

a.

Element property

c.

Length property

b.

getSize method

d.

GetBounds method

12. C# provides a special loop known as the __________ loop that automatically iterates once for each element in the array.

a.

do-while

b.

foreach

c.

for

d.

while

13. The __________ is a container that can hold multiple images.

a.

ImageList control

c.

Panel control

b.

PictureBox control

d.

Bitmap

14. If you know the __________ value for a particular image, you can retrieve that image from the ImageList control and display it in a PictureBox.

a.

reference

b.

index

c.

Boolean

d.

image

15. In code, you can determine the number of images stored in an ImageList control by getting the value of the control's __________ property.

a.

Image.List.Max

c.

Images.Count

b.

Size.Get

d.

GetLastImage

16. The foreach loop is designed to work with a temporary, read-only variable known as the __________variable.

a.

loop

b.

counter

c.

iteration

d.

foreach

17. Because arrays are always passed __________, a method that receives an array as an argument has access to the actual array.

a.

by value

b.

globally

c.

in memory

d.

by reference

18. The __________ algorithm uses a loop to step through the elements in an array, one by one, from the first to the last.

a.

sequential search

c.

binary search

b.

optimized search

d.

basic array traversal

19. To compare the contents of two arrays, you must compare each of the __________ in the two arrays.

a.

memory locations

c.

elements

b.

reference variables

d.

types

20. When you process a __________, you must process only elements containing valid items.

a.

partially filled array

c.

sequential search

b.

reference copy

d.

Boolean expression

21. To successfully __________ the contents of two variables, you need a third variable that serves as a temporary storage location.

a.

copy

b.

exchange

c.

reference

d.

remove

22. __________ arrays can hold only one set of data.

a.

One-dimensional

c.

Data bound

b.

Two-dimensional

d.

Classical

23. To declare a two-dimensional array two __________ are required. The first one is for the number of rows and the second one is for the number of columns.

a.

reference variables

c.

named constants

b.

Boolean variables

d.

size declarators

24. Given the following code sample, what is the total number of elements in the grid array?

const int ROWS = 2;

const int COLS = 2;

int[, ] grid = new int[ROWS, COLS];

a.

2

b.

4

c.

8

d.

16

25. Given the following code sample, which of the statements below stores the value 25 in the element located at the first row, second column of the table array?

const int ROWS = 8;

const int COLS = 2;

int[, ] table = new int[ROWS, COLS];

a.

table[1, 2] = 25;

c.

table[2, 1] = 25;

b.

table[0, 1] = 25;

d.

table[1, 0] = 25;

26. Given the following code sample, what value is stored in values[1, 2]?

int[, ] values = { {1, 2, 3, 4},

(5, 6, 7, 8} };

a.

2

b.

3

c.

6

d.

7

27. A(n) __________ array is similar to a two-dimensional array but the rows can have different numbers of columns.

a.

offset

b.

skewed

c.

jagged

d.

differential

28. A __________ is similar to an array but it can expand at runtime.

a.

List object

c.

Random object

b.

sequential object

d.

jagged array

29. Which of the following statements correctly creates a List object named friendsList that holds strings?

a.

string friendsList = new List<string>;

b.

<List> friendsList(string);

c.

List<string> friendsList = new List<string>;

d.

List<string> friendsList = new List<string>();

30. To add items to an existing List object, use the __________.

a.

+= operator

c.

& operator

b.

Insert property

d.

Add method

31. A List object has a __________ property that holds the number of items stored in the List.

a.

Count

b.

Total

c.

Length

d.

Size

32. You can call the __________ method to insert an item at a specific index position in a List object.

a.

Put

b.

Add

c.

Insert

d.

Place

33. If you want to take out all items from a List object, call the __________ method.

a.

Clear

b.

Reset

c.

ClearAll

d.

ReDim

34. If you know the value of the item you want to take out from a List object but you do not know the item's index, you can use the __________.

a.

- (minus) operator

c.

Remove method

b.

Erase method

d.

Delete method

35. List objects are always passed to methods __________.

a.

by value

c.

by reference

b.

in memory

d.

globally

Document Information

Document Type:
DOCX
Chapter Number:
7
Created Date:
Aug 21, 2025
Chapter Name:
Chapter 7 Arrays And Lists
Author:
Tony Gaddis

Connected Book

Test Bank | Visual C# 5e

By Tony Gaddis

Test Bank General
View Product →

$24.99

100% satisfaction guarantee

Buy Full Test Bank

Benefits

Immediately available after payment
Answers are available after payment
ZIP file includes all related files
Files are in Word format (DOCX)
Check the description to see the contents of each ZIP file
We do not share your information with any third party