# CHAPTER07

Topics: Array, C, Data type Pages: 46 (5365 words) Published: January 25, 2015
Chapter 7 Arrays
Section 7.1 Creating and Using Arrays
1.

After the following Dim statement is executed, how many elements will the array myVar have?
Dim myVar(7) As Double

(A)
(B)
(C)
(D)
2.

0
1
8
9
C

In the line of code
Dim scores() As Integer = {55, 33, 12}

the upper bound of the array scores is which of the following? (A)
(B)
(C)
(D)
3.

2
1
11
0
A

Each individual variable in the list
student(0), student(1), student(2)

is known as a(n)
(A)
(B)
(C)
(D)
4.

subscript.
dimension.
element.
type.
C

In the statement
Dim scores(30) As Double

the number 30 designates which of the following?
(A)
(B)
(C)
(D)

the highest value of the subscripts of the elements for the array scores the maximum value that can be assigned to any element in the array scores the data type for the array scores
the value initially assigned to each element in the array scores A

5.

Which statement is true regarding the following Dim statement? Dim states(49) As String, populations(49) As Double

(A)
(B)
(C)
(D)
6.

It is invalid since more than one array is dimensioned by a single Dim statement. It is invalid since the two arrays must have the same data type. The subscripts of states range from 1 to 49.
The subscripts of populations range from 0 To 49.
D

The Count method returns what information about an array?
(A) the highest number that can be used as a subscript for the array (B) the largest value that can be assigned to an array element (C) the number of elements in the array
(D)tThe highest dimension of the array
C

7.

In the line of code
For index As Integer = 0 to (score.Count - 1)

the Count method is used to carry out which of the following tasks? (A)
(B)
(C)
(D)
8.

The ReDim statement causes an array to lose its current contents unless the word ReDim is followed by the keyword
(A)
(B)
(C)
(D)

9.

determine the largest value for each of the elements
determine the largest subscript in the array
determine the smallest value for each of the elements
declare a new array with the name Count
B

CInt
MyBase
Preserve
C

Like other variables, array variables can be declared and assigned initial values at the same time. (T/F)
T

10. After an array has been declared, its type (but not its size) can be changed with a ReDim statement. (T/F)
F
11. If you use the ReDim statement to make an array smaller than it was, data in the eliminated elements can be retrieved by using the Preserve keyword. (T/F) F

12. What will be the size of the array stones after the following two lines of code are executed? Dim stones() As String = {"Watts", "Jagger", "Wood", "Richards"} ReDim Preserve stones(10)

11
13. The statement
Dim newlist(10) As String

is used to declare an array where each element has the value 10. (T/F) F
14. In the line of code
Function Sum(scores() As Integer) As Integer

the pair of parentheses that follows scores can be removed. (T/F) F
15. In the line of code
Dim scores() As Integer = {55, 33, 12}

the upper bound of the array scores is 12. (T/F)
F
16. What two names are displayed in the list box when the button is clicked on? Dim krispies() as String
krispies(0) = "snap"
krispies(1) = "crackle"
krispies(2) = "pop"
End Sub
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
End Sub

(A)
(B)
(C)
(D)

crackle and pop
crackle and snap
snap and crackle
snap and pop
D

17. What two numbers are displayed in the list box when the button is clicked on? Dim nums() as Integer
Private Sub
nums(0) =
nums(1) =
nums(2) =
End Sub

5
3
4

Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
End Sub

(A)
(B)
(C)
(D)

4 and 5
4 and 4
3 and 5
3 and...