Chapter Questions
In an array, every element has the same ______________a. subscriptc. data typeb. memory locationd. all of the above
The operator used to create objects is ______________a. $=$c. newb. $+=$d. create
Which of the following correctly declares an array of six integers?a. int array[6];c. int[6] array;b. int [] array $=6$;d. int [] array $=$ new int $[6]$;
The value placed within square brackets after an array name is ______________a. always a constantc. called a subscriptb. always a doubled. all of these
If you define an array to contain 10 elements, then the highest array subscript you can use is ______________a. 8c. 10b. 9d. 11
Initializing an array is ______________ in $\mathrm{CH}$.a. optionalc. difficultb. requiredd. prohibited
When you declare an array of six double elements but provide no initialization values, the value of the first element is ______________a. 0.0c. 5.0b. 1.0d. unknown
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
When an ages array is correctly initialized using the values $\{20,30,40,50\}$, then the value of ages [1] is ______________a. 0c. 30b. 20d. undefined
When an ages array is correctly initialized using the values $\{20,30,40,50\}$, then the value of ages [4] is ______________a. 0c. 50b. 4d. undefined
When you declare an array as int [] temperature $=\{0,32,50,90,212$, 451\}; , the value of temperature. Length is ______________a. 5c. 7b. 6d. unknown
Which of the following doubles every value in a 10-element integer array named amount?a. for (int $x=9 ; x>=0 ;--x$ ) amount $[x]==2$;b. foreach(int number in amount) number ${ }^{\star}=2$;c. both of thesed. neither of these
Which of the following adds 10 to every value in a 16 -element integer array named points?a. for(int sub $=0$; sub $>16$; ++sub) points[sub] += 10 ;b. foreach(int sub in points) points $+=10$;c. both of thesed. neither of these
Two arrays that store related information in corresponding element positions are ______________ arrays.a. jaggedc. relativeb. paralleld. rectangular
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)$Write (nums $[x]$ );b. for(int $x=3 ; x>=0 ;--x$ )Write (nums $[x]$ );c. for (int $x=3 ; x>0 ;--x)$Write (nums $[x])$;d. for (int $x=4 ; x>=0 ;--x$ )Write (nums $[x]$ );
Assume an array is defined 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);
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. They both operate only arrays made up of numeric data.c. The array that each method uses must start in ascending order.d. Both methods belong to the System.Array class.
If you use the BinarySearch() method, and the object you seek is not found in the array, ______________a. an error message is displayedc. the value fa1se is returnedb. a zero is returnedd. a negative value is returned
The BinarySearch () method is inadequate when ______________a. array items are in ascending orderb. the array holds duplicate values and you want to find them allc. you want to find an exact match for a valued. array items are not numeric
Which of the following declares an integer array that contains eight rows and five columns?a. $\operatorname{int}[8,5]$ num $=$ new $\operatorname{int}[$,$] ;$b. int $[8][5]$ num $=$ new int [] ;c. int $[$,$] num = new int [5,8]$;d. int $[$,$] num =$ new int $[8,5]$;