Deck 8: Arrays and More
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/34
Play
Full screen (f)
Deck 8: Arrays and More
1
Which of the following could be used to iterate through each element of a two-dimensional array.
A) A single Do While loop
B) A single Do Until loop
C) A single For…Next loop
D) Nested For…Next loops
A) A single Do While loop
B) A single Do Until loop
C) A single For…Next loop
D) Nested For…Next loops
D
2
What happens to most controls when the Enabled property is set to False?
A) The control responds to events generated by the user.
B) The control can receive the focus
C) The control appears grayed out, or dimmed
D) The control does not appear
A) The control responds to events generated by the user.
B) The control can receive the focus
C) The control appears grayed out, or dimmed
D) The control does not appear
C
3
This property of a control allows it be positioned a specified distance from the outside edge of the form.
A) dock
B) anchor
C) attach
D) secure
A) dock
B) anchor
C) attach
D) secure
B
4
Values in an array are stored and worked with using a __________.
A) method
B) locator
C) subscript
D) element locator
A) method
B) locator
C) subscript
D) element locator
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
5
Which of the following statements sorts an array named intValues?
A) Sort.Array(intValues)
B) Sort(intValues)
C) Sort.Array(intValues())
D) Array.Sort(intValues)
A) Sort.Array(intValues)
B) Sort(intValues)
C) Sort.Array(intValues())
D) Array.Sort(intValues)
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
6
Which of the following allows an application to automatically execute code at regular time intervals?
A) Timer Enabled Event
B) Interval Property
C) Timer Event
D) Timer control
A) Timer Enabled Event
B) Interval Property
C) Timer Event
D) Timer control
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
7
Which statement is the best solution for the following problem? Write a statement that initializes a two-dimensional array of Integers named intGrades. The array will have 2 rows, with 93, 91, and 84 in the first row and 85, 89, and 91 in the second row.
A) Dim intGrades(2,3) As Integer = { {93, 91, 84}, {85, 89, 91} }
B) Dim intGrades(,) As Integer = { {93, 91, 84}, {85, 89, 91} }
C) Dim intGrades() As Integer = { 93, 92, 84,85, 89, 91}
D) Dim intGrades(1, 2) As Integer = { {93, 91, 84}, {85,89, 91} }
A) Dim intGrades(2,3) As Integer = { {93, 91, 84}, {85, 89, 91} }
B) Dim intGrades(,) As Integer = { {93, 91, 84}, {85, 89, 91} }
C) Dim intGrades() As Integer = { 93, 92, 84,85, 89, 91}
D) Dim intGrades(1, 2) As Integer = { {93, 91, 84}, {85,89, 91} }
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
8
The lowest possible subscript of an array is __________.
A) 0
B) 1
C) −1
D) There is no limit
A) 0
B) 1
C) −1
D) There is no limit
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
9
What is the error in the following code, and when will it be caught? Dim intValues(5) As Integer
Dim intIndex As Integer
For intIndex = 0 To 10
IntValues(intIndex) = 10
Next intIndex
A) The For...Next loop values for intIndex should range from 1 to 10. The error will occur at run time.
B) The loop should close with Next instead of Next intIndex. The error will occur at compile time.
C) An IndexOutOfRangeException will be thrown
D) The For...Next loop values for intIndex should range from 1 to 5. The error will occur at compile time.
Dim intIndex As Integer
For intIndex = 0 To 10
IntValues(intIndex) = 10
Next intIndex
A) The For...Next loop values for intIndex should range from 1 to 10. The error will occur at run time.
B) The loop should close with Next instead of Next intIndex. The error will occur at compile time.
C) An IndexOutOfRangeException will be thrown
D) The For...Next loop values for intIndex should range from 1 to 5. The error will occur at compile time.
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
10
Which of the following code segments will copy the values of a 5 element array named intOldValues into another 5 element array named intNewValues?
A) intIndex = 1 Do While intIndex < =5
IntNewValues(intIndex) = intOldValues(intIndex)
IntIndex = intIndex + 1
Loop
B) intIndex = 0 Do While intIndex < 5
IntNewValues(intIndex) = intOldValues(intIndex)
IntIndex = intIndex + 1
Loop
C) For intIndex = 1 To 5 intNewValues(intIndex) = intOldValues(intIndex)
Next intIndex
D) For intIndex = 0 To 4 intOldValues(intIndex) = intNewValues(intIndex)
Next intIndex
A) intIndex = 1 Do While intIndex < =5
IntNewValues(intIndex) = intOldValues(intIndex)
IntIndex = intIndex + 1
Loop
B) intIndex = 0 Do While intIndex < 5
IntNewValues(intIndex) = intOldValues(intIndex)
IntIndex = intIndex + 1
Loop
C) For intIndex = 1 To 5 intNewValues(intIndex) = intOldValues(intIndex)
Next intIndex
D) For intIndex = 0 To 4 intOldValues(intIndex) = intNewValues(intIndex)
Next intIndex
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
11
When changing the number of elements in an array at run-time with the ReDim statement, existing values in the array are destroyed unless the ______keyword is used.
A) Preserve
B) Reserve
C) ReDim
D) Protect
A) Preserve
B) Reserve
C) ReDim
D) Protect
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
12
Which of the following provides the index of the highest numbered element of the array strNames?
A) strNames.Length - 1
B) strNames.Length
C) strNames.Length + 1
D) None of the above
A) strNames.Length - 1
B) strNames.Length
C) strNames.Length + 1
D) None of the above
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
13
Which of the following statements defines a two-dimensional Integer array named intTwoDArray with 6 rows and 4 columns?
A) Dim intTwoDArray(5, 3) As Integer
B) Dim intTwoDArray(3, 5) As Integer
C) Dim intTwoDArray(6, 4) As Integer
D) Dim intTwoDArray(4, 6) As Integer
A) Dim intTwoDArray(5, 3) As Integer
B) Dim intTwoDArray(3, 5) As Integer
C) Dim intTwoDArray(6, 4) As Integer
D) Dim intTwoDArray(4, 6) As Integer
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
14
What task is accomplished by the following code? Dim intFirstArray(2) As Integer
Dim intSecondArray(2) As Integer
IntFirstArray(0) = 10
IntFirstArray(1) = 19
IntFirstArray(2) = 26
IntSecondArray = intFirstArray
A) Two distinct arrays are created in memory with the same values.
B) intFirstArray and intSecondArray reference the same array in memory
C) This code will generate a run-time error. You cannot assign the name of one array to another.
D) intFirstArray is initialized with values but intSecondArray contains no values
Dim intSecondArray(2) As Integer
IntFirstArray(0) = 10
IntFirstArray(1) = 19
IntFirstArray(2) = 26
IntSecondArray = intFirstArray
A) Two distinct arrays are created in memory with the same values.
B) intFirstArray and intSecondArray reference the same array in memory
C) This code will generate a run-time error. You cannot assign the name of one array to another.
D) intFirstArray is initialized with values but intSecondArray contains no values
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
15
Assume that an integer array named intValues contains intNUM elements. Which of the following code segments most efficiently finds the largest element in the array and displays it in a label named lblMaxValue? Assume that values have already been inserted into the array.
A) For intIndex = 0 To intNUM - 1 If (intValues(intIndex) > CInt(txtMax.Text)) Then
LblMaxValue.Text = intValues(intIndex).ToString
End If
Next intIndex
B) intMax = intValues(0) For intIndex = 1 to intValues.length - 1
If intValues(intIndex) > intMax Then
IntMax = intValues(intIndex)
End If
Next
LblMaxValue.text = intMax.ToString
C) For intIndex = 0 To intNUM If intValues(intIndex) > intMax Then
IntValues(intIndex) = intMax
End If
Next
LblMaxValue.Text = intMax.ToString
D) intMax = intValues(0) For intIndex = 1 To intValues.length
If intValues(intIndex) > intMax) Then
IntMax = intValues(intIndex)
LblMaxValue.Text = intMax.ToString
End If
Next
A) For intIndex = 0 To intNUM - 1 If (intValues(intIndex) > CInt(txtMax.Text)) Then
LblMaxValue.Text = intValues(intIndex).ToString
End If
Next intIndex
B) intMax = intValues(0) For intIndex = 1 to intValues.length - 1
If intValues(intIndex) > intMax Then
IntMax = intValues(intIndex)
End If
Next
LblMaxValue.text = intMax.ToString
C) For intIndex = 0 To intNUM If intValues(intIndex) > intMax Then
IntValues(intIndex) = intMax
End If
Next
LblMaxValue.Text = intMax.ToString
D) intMax = intValues(0) For intIndex = 1 To intValues.length
If intValues(intIndex) > intMax) Then
IntMax = intValues(intIndex)
LblMaxValue.Text = intMax.ToString
End If
Next
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
16
Which of the following code segments is the correct solution for the following problem? Find the first occurrence of the value "Joe" in the array strNames. Save the index of the element containing "Joe" in a variable named intPosition. Discontinue searching the array once the first occurrence of the element "Joe" has been located. Assume any variables you need are already defined.
A) For intCount = 0 To strNames.length-1 If strNames(intCount) = "Joe" Then
IntPosition = intCount
End If
Next
B) blnFound = True intCount = 0
Do While (Not blnFound) And (intCount < = strNames.Length - 1)
If strNames(intCount) = "Joe" Then
BlnFound = False
Positon = intCount
End If
IntCount += 1
Loop
C) blnFound = False intCount = 0
Do While (Not blnFound) And (intCount < strNames.Length)
If strNames(intCount) = "Joe" Then
BlnFound = True
IntPosition = intCount
End If
IntCount += 1
Loop
D) blnFound = False For intCount = 0 to strNames.Length -1 and Not blnFound
If strNames(intCount) = "Joe" Then
BlnFound = True
IntPosition = intCount
End If
Next
A) For intCount = 0 To strNames.length-1 If strNames(intCount) = "Joe" Then
IntPosition = intCount
End If
Next
B) blnFound = True intCount = 0
Do While (Not blnFound) And (intCount < = strNames.Length - 1)
If strNames(intCount) = "Joe" Then
BlnFound = False
Positon = intCount
End If
IntCount += 1
Loop
C) blnFound = False intCount = 0
Do While (Not blnFound) And (intCount < strNames.Length)
If strNames(intCount) = "Joe" Then
BlnFound = True
IntPosition = intCount
End If
IntCount += 1
Loop
D) blnFound = False For intCount = 0 to strNames.Length -1 and Not blnFound
If strNames(intCount) = "Joe" Then
BlnFound = True
IntPosition = intCount
End If
Next
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
17
Which of the following is the correct definition for a procedure that accepts a String array as an argument?
A) Private Sub ArrayParam(ByVal strStudents As String)
B) Public Sub ArrayParam(ByVal strStudents())
C) Sub ArrayParam(ByVal strStudents() As String)
D) Private Sub ArrayParam(ByRef strStudents As String)
A) Private Sub ArrayParam(ByVal strStudents As String)
B) Public Sub ArrayParam(ByVal strStudents())
C) Sub ArrayParam(ByVal strStudents() As String)
D) Private Sub ArrayParam(ByRef strStudents As String)
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
18
Due to their similarities, it's easy to create a parallel relationship between an array and a __________.
A) TextBox
B) GroupBox
C) ComboBox
D) RadioButton
A) TextBox
B) GroupBox
C) ComboBox
D) RadioButton
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
19
Which of the following code segments displays each element in an Integer array named intValues without using an index to reference the items in the array.
A) Dim intCount As Integer For intCount = 0 To (intValues.Length - 1)
MessageBox.Show(intValues(intCount).ToString)
Next intCount
B) For intCount = 1 To IntValues.Length MessageBox.Show(intValues(intCount).ToString)
Next
C) For Each strElement As String In intValues MessageBox.Show(strElement)
Next
D) For Each intNumber as Integer In intValues MessageBox.Show(intNumber.ToString)
Next
A) Dim intCount As Integer For intCount = 0 To (intValues.Length - 1)
MessageBox.Show(intValues(intCount).ToString)
Next intCount
B) For intCount = 1 To IntValues.Length MessageBox.Show(intValues(intCount).ToString)
Next
C) For Each strElement As String In intValues MessageBox.Show(strElement)
Next
D) For Each intNumber as Integer In intValues MessageBox.Show(intNumber.ToString)
Next
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
20
In the array declaration below, what is the significance of the number 7? Dim strNames(7) As String
A) It indicates the number of elements in the array.
B) It's the upper bound (highest subscript value) of the array.
C) It's the value assigned to the array elements.
D) It's one greater than the upper bound of the array.
A) It indicates the number of elements in the array.
B) It's the upper bound (highest subscript value) of the array.
C) It's the value assigned to the array elements.
D) It's one greater than the upper bound of the array.
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
21
What does the following section of code accomplish? Dim intCount as Integer
Dim intXXXX as Integer = intNumbers(0)
For intCount = 1 to (inNumbers.Length - 1)
If intNumbers(intCount) > intXXXX Then
IntXXXX = intNumbers(intCount)
End If
Next intCount
A) Finds the first element of the array intNumbers
B) Finds the last element of the array intNumbers
C) Finds the Highest value in the array intNumbers
D) Finds the Lowest value in the array intNumbers
Dim intXXXX as Integer = intNumbers(0)
For intCount = 1 to (inNumbers.Length - 1)
If intNumbers(intCount) > intXXXX Then
IntXXXX = intNumbers(intCount)
End If
Next intCount
A) Finds the first element of the array intNumbers
B) Finds the last element of the array intNumbers
C) Finds the Highest value in the array intNumbers
D) Finds the Lowest value in the array intNumbers
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
22
Which one of the following declares a List variable and creates a List object at the same time.
A) New lstNames As List Of String
B) lstNames As String Object
C) Dim lstNames As New String
D) Dim lstNames As New List(Of String)
A) New lstNames As List Of String
B) lstNames As String Object
C) Dim lstNames As New String
D) Dim lstNames As New List(Of String)
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
23
Which of the following declares an array to contain the weekly sales of a group of salespeople for a year? (use the constant intNumSalesmen for the number of salesmen and 52 for the number of weeks)
A) Dim decWeeklySalesTotal(intNumSalesmen - 1, 52 - 1) as Decimal
B) Dim decWeeklySalesTotal(intNumSalesmen - 1, 52) as Decimal
C) Dim decWeeklySalesTotal(intNumSalesmen - 1, 52 - 1)
D) Dim decWeeklySalesTotal(intNumSalesmen, 52) as Decimal
A) Dim decWeeklySalesTotal(intNumSalesmen - 1, 52 - 1) as Decimal
B) Dim decWeeklySalesTotal(intNumSalesmen - 1, 52) as Decimal
C) Dim decWeeklySalesTotal(intNumSalesmen - 1, 52 - 1)
D) Dim decWeeklySalesTotal(intNumSalesmen, 52) as Decimal
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
24
The following statements apply to a Timer control, except _____________.
A) it can be used to trigger tick events at regular intervals
B) the smallest possible interval between tick events is a microsecond
C) the timer can be disabled so it generates no tick events
D) it responds to Tick events only at run time
A) it can be used to trigger tick events at regular intervals
B) the smallest possible interval between tick events is a microsecond
C) the timer can be disabled so it generates no tick events
D) it responds to Tick events only at run time
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
25
What is the best way to describe the following array? Dim decCars (5, 10, 2) As Decimal
A) it is a 100 element array
B) it contains 5 sets of 10 rows, each containing 2 parts
C) it contains 5 rows with 10 columns, each with 2 sections
D) it contains 6 sets of 11 rows, each containing 3 columns
A) it is a 100 element array
B) it contains 5 sets of 10 rows, each containing 2 parts
C) it contains 5 rows with 10 columns, each with 2 sections
D) it contains 6 sets of 11 rows, each containing 3 columns
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
26
What does the following section of code accomplish? Dim intCount as Integer
Dim intXXXX as Integer = intNumbers(0)
For intCount = 1 to (inNumbers.Length - 1)
If intNumbers(intCount) < intXXXX Then
IntXXXX = intNumbers(intCount)
End If
Next intCount
A) Finds the first element of the array intNumbers
B) Finds the last element of the array intNumbers
C) Finds the Highest value in the array intNumbers
D) Finds the Lowest value in the array intNumbers
Dim intXXXX as Integer = intNumbers(0)
For intCount = 1 to (inNumbers.Length - 1)
If intNumbers(intCount) < intXXXX Then
IntXXXX = intNumbers(intCount)
End If
Next intCount
A) Finds the first element of the array intNumbers
B) Finds the last element of the array intNumbers
C) Finds the Highest value in the array intNumbers
D) Finds the Lowest value in the array intNumbers
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
27
Parallel arrays have all of the following characteristics, except __________.
A) They can access related elements with a common subscript.
B) They share a reference to the same array.
C) They hold related data of different types.
D) They are two or more arrays that hold related data.
A) They can access related elements with a common subscript.
B) They share a reference to the same array.
C) They hold related data of different types.
D) They are two or more arrays that hold related data.
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
28
Procedures can be written to handle arrays and do all of the following, except __________.
A) store data in an array
B) sum or average the values
C) display the contents of the array
D) all of the above are correct
A) store data in an array
B) sum or average the values
C) display the contents of the array
D) all of the above are correct
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
29
How many elements can be stored in the following array? Dim sngGrades (2, 3) As Single
A) 6
B) 5
C) 12
D) cannot be determined
A) 6
B) 5
C) 12
D) cannot be determined
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
30
Which of the following code segments sets all elements of the array strStudentNames to the value NONE?
A) Dim intCount as Integer For intCount = 1 to (strStudentNames.Length - 1)
StrStudentNames(intCount) = "NONE"
Next intCount
B) Dim intCount as Integer For intCount = 0 to (strStudentNames.Length - 1)
StrStudentNames(intCount) = "NONE"
Next intCount
C) Dim intCount as Integer For intCount = 0 to (strStudentNames.Length)
StrStudentNames(intCount) = "NONE"
Next intCount
D) Dim intCount as Integer For intCount = 1 to (strStudentNames.Length)
StrStudentNames(intCount) = "NONE"
Next intCount
A) Dim intCount as Integer For intCount = 1 to (strStudentNames.Length - 1)
StrStudentNames(intCount) = "NONE"
Next intCount
B) Dim intCount as Integer For intCount = 0 to (strStudentNames.Length - 1)
StrStudentNames(intCount) = "NONE"
Next intCount
C) Dim intCount as Integer For intCount = 0 to (strStudentNames.Length)
StrStudentNames(intCount) = "NONE"
Next intCount
D) Dim intCount as Integer For intCount = 1 to (strStudentNames.Length)
StrStudentNames(intCount) = "NONE"
Next intCount
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
31
In Visual Basic you can use the ______data type to hold a set of items.
A) Group
B) List
C) Array
D) Object
A) Group
B) List
C) Array
D) Object
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
32
What value should be placed in a Timer control's Interval property to trigger a Tick event every 10 seconds?
A) 1000
B) 10000
C) 100
D) 10
A) 1000
B) 10000
C) 100
D) 10
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
33
Which statement is not true about the following array? Dim strFriends() As String = { "Rose", "Bud", "Flower", "Spring" }
A) The String "Flower" is located at index position 2.
B) All elements have been assigned values.
C) The array has an unlimited number of elements.
D) All of the above are true statements about the array.
A) The String "Flower" is located at index position 2.
B) All elements have been assigned values.
C) The array has an unlimited number of elements.
D) All of the above are true statements about the array.
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
34
Which type of loop is designed specifically to use a subscript to access the elements of an array?
A) For…Next
B) Do While
C) Do Until
D) For While
A) For…Next
B) Do While
C) Do Until
D) For While
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck