• Home
  • Textbooks
  • Microsoft Visual C# 2017: An Introduction to Object-Oriented Programming
  • Using Arrays

Microsoft Visual C# 2017: An Introduction to Object-Oriented Programming

Joyce Farrell

Chapter 6

Using Arrays - all with Video Answers

Educators


Chapter Questions

00:43

Problem 1

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

Aditya Sood
Aditya Sood
Numerade Educator

Problem 2

The operator used to create objects is ______________
a. $=$
c. new
b. $+=$
d. create

Check back soon!

Problem 3

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]$;

Check back soon!

Problem 4

The value placed within square brackets after an array name is ______________
a. always a constant
c. called a subscript
b. always a double
d. all of these

Check back soon!
03:02

Problem 5

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

Ernest Castorena
Ernest Castorena
Numerade Educator
01:39

Problem 6

Initializing an array is ______________ in $\mathrm{CH}$.
a. optional
c. difficult
b. required
d. prohibited

Manik Pulyani
Manik Pulyani
Numerade Educator
00:34

Problem 7

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

Aditya Sood
Aditya Sood
Numerade Educator
01:39

Problem 8

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

Manik Pulyani
Manik Pulyani
Numerade Educator
01:14

Problem 9

When an ages array is correctly initialized using the values $\{20,30,40,50\}$, then the value of ages [1] is ______________
a. 0
c. 30
b. 20
d. undefined

Lily An
Lily An
Numerade Educator

Problem 10

When an ages array is correctly initialized using the values $\{20,30,40,50\}$, then the value of ages [4] is ______________
a. 0
c. 50
b. 4
d. undefined

Check back soon!
00:59

Problem 11

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

Aditya Sood
Aditya Sood
Numerade Educator
00:51

Problem 12

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 these
d. neither of these

Aditya Sood
Aditya Sood
Numerade Educator
00:55

Problem 13

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 these
d. neither of these

Aditya Sood
Aditya Sood
Numerade Educator
02:43

Problem 14

Two arrays that store related information in corresponding element positions are ______________ arrays.
a. jagged
c. relative
b. parallel
d. rectangular

Bharat Koirala
Bharat Koirala
Numerade Educator
01:39

Problem 15

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]$ );

Manik Pulyani
Manik Pulyani
Numerade Educator

Problem 16

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);

Check back soon!

Problem 17

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.

Check back soon!
00:28

Problem 18

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

Aditya Sood
Aditya Sood
Numerade Educator

Problem 19

The 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

Check back soon!
04:14

Problem 20

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]$;

Ernest Castorena
Ernest Castorena
Numerade Educator