ISDS 309 Chapter 6

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

If you use the BinarySearch() method and the object you seek is not found in the array,_____________ . a. an error message is displayed b. a zero is returned c. the value false is returned d. a negative value is returned

a negative value is returned

The value placed within square brackets after an array name is . a. a subscript b. an index c. always an integer d. all of these

all of these

Which of the following correctly declares an array of four integers? a. int[] ages = new int[4] {20, 30, 40, 50}; b. int[] ages = new int[] {20, 30, 40, 50}; c. int[] ages = {20, 30, 40, 50}; d. all of these

all of these

Which of the following doubles every value in a ten-element integer array named amount? a. for(int x = 9; x >= 0; --x) amount[x] *= 2; b. foreach(int number in amount) number *= 2; c. both of these d. neither of these

both of these

In an array, every element has the same_______. a. subscript b. data type c. memory location d. all of the above

data type

Assume an array is defined as int[] nums = {2, 3, 4, 5};. Which of the following would display the values in the array in reverse? a. for(int x = 4; x > 0; --x) Console.Write(nums[x]); b. for(int x = 3; x >= 0; --x) Console.Write(nums[x]); c. for(int x = 3; x > 0; --x) Console.Write(nums[x]); d. for(int x = 4; x >= 0; --x) Console.Write(nums[x]);

for(int x = 3; x >= 0; --x) Console.Write(nums[x]);

Which of the following declares an integer array that contains eight rows and five columns? a. int[8, 5] num = new int[ , ]; b. int [8][5] num = new int[]; c. int [ , ] num = new int[5, 8]; d. int [ , ] num = new int[8, 5];

int [ , ] num = new int[8, 5];

Th e BinarySearch() method is inadequate when__________________ . a. array items are in ascending order b. the array holds duplicate values and you want to find them all c. you want to find an exact match for a value d. array items are not numeric

the array holds duplicate values and you want to fi nd them all

When an ages array is correctly initialized using the values {20, 30, 40, 50}, as in Question 8, then the value of ages[4] is____________ . a. 0 b. 4 c. 50 d. undefined

undefined

When you declare an array of six double elements but provide no initialization values, the value of the fi rst element is . a. 0.0 b. 1.0 c. 5.0 d. unknown

0.0

When an ages array is correctly initialized using the values {20, 30, 40, 50}, as in Question 8, then the value of ages[1] is ___________________. a. 0 b. 20 c. 30 d. undefined

30

When you declare an array as int[] temperature = {0, 32, 50, 90, 212, 451};, the value of temperature.Length is ___________________. a. 5 b. 6 c. 7 d. unknown

6

If you define an array to contain 10 elements, then the highest array subscript you can use is . a. 11 b. 10 c. 9 d. 8

9

Which of the following correctly declares an array of six integers? a. int array[6] b. int[] array = 6 c. int[6] array; d. int[] array = new int[6];

int[] array = new int[6];

Which of the following adds 10 to every value in a 16-element integer array named points? a. for(int sub = 0; sub > 15; ++sub) points[sub] += 10; b. foreach(int sub in points) points += 10; c. both of these d. neither of these

neither of these

The operator used to create object is________. a. = b. += c. new d. create

new

Initializing an array is in C#. a. required b. optional c. difficult d. prohibited

optional

Two arrays that store related information in corresponding element positions are _______________. a. analogous arrays b. polymorphic arrays c. relative arrays d. parallel arrays

parallel arrays

Assume an array is defi ned as int[] nums = {7, 15, 23, 5};. Which of the following would place the values in the array in descending numeric order? a. Array.Sort(nums); b. Array.Reverse(nums); c. Array.Sort(nums); Array.Reverse(nums); d. Array.Reverse(nums); Array.Sort(nums);

Array.Sort(nums); Array.Reverse(nums);

Which of the following traits do the BinarySearch() and Sort() methods have in common? a. Both methods take a single argument that must be an array. b. Both methods belong to the System.Array class. c. Th e array that each method uses must be in ascending order. d. Th ey both operate on arrays made up of simple data types but not class objects.

Both methods belong to the System.Array class.


Ensembles d'études connexes

english exam: literature and "Inn of Lost Time"

View Set

Part 2 of Developmental Psychology

View Set