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 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
D
2
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
3
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
4
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
5
Which of the following is the correct definition for a procedure that accepts a String array as an argument?
A) Private Sub ArrayParamByVal strStudents As String)
B) Public Sub ArrayParamByVal strStudents))
C) Sub ArrayParamByVal strStudents) As String)
D) Private Sub ArrayParamByRef strStudents As String)
A) Private Sub ArrayParamByVal strStudents As String)
B) Public Sub ArrayParamByVal strStudents))
C) Sub ArrayParamByVal strStudents) As String)
D) Private Sub ArrayParamByRef strStudents As String)
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
6
What task is accomplished by the following code? Dim intFirstArray2) As Integer
Dim intSecondArray2) As Integer
IntFirstArray0) = 10
IntFirstArray1) = 19
IntFirstArray2) = 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 intSecondArray2) As Integer
IntFirstArray0) = 10
IntFirstArray1) = 19
IntFirstArray2) = 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
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 intGrades2,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 intGrades1, 2) As Integer = { {93, 91, 84}, {85,89, 91} }
A) Dim intGrades2,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 intGrades1, 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
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
9
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
IntNewValuesintIndex) = intOldValuesintIndex)
IntIndex = intIndex + 1
Loop
B) intIndex = 0 Do While intIndex < 5
IntNewValuesintIndex) = intOldValuesintIndex)
IntIndex = intIndex + 1
Loop
C) For intIndex = 1 To 5 intNewValuesintIndex) = intOldValuesintIndex)
Next intIndex
D) For intIndex = 0 To 4 intOldValuesintIndex) = intNewValuesintIndex)
Next intIndex
A) intIndex = 1 Do While intIndex < =5
IntNewValuesintIndex) = intOldValuesintIndex)
IntIndex = intIndex + 1
Loop
B) intIndex = 0 Do While intIndex < 5
IntNewValuesintIndex) = intOldValuesintIndex)
IntIndex = intIndex + 1
Loop
C) For intIndex = 1 To 5 intNewValuesintIndex) = intOldValuesintIndex)
Next intIndex
D) For intIndex = 0 To 4 intOldValuesintIndex) = intNewValuesintIndex)
Next intIndex
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
10
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 intValuesintIndex) > CInttxtMax.Text)) Then
LblMaxValue.Text = intValuesintIndex).ToString
End If
Next intIndex
B) intMax = intValues0) For intIndex = 1 to intValues.length - 1
If intValuesintIndex) > intMax Then
IntMax = intValuesintIndex)
End If
Next
LblMaxValue.text = intMax.ToString
C) For intIndex = 0 To intNUM If intValuesintIndex) > intMax Then
IntValuesintIndex) = intMax
End If
Next
LblMaxValue.Text = intMax.ToString
D) intMax = intValues0) For intIndex = 1 To intValues.length
If intValuesintIndex) > intMax) Then
IntMax = intValuesintIndex)
LblMaxValue.Text = intMax.ToString
End If
Next
A) For intIndex = 0 To intNUM - 1 If intValuesintIndex) > CInttxtMax.Text)) Then
LblMaxValue.Text = intValuesintIndex).ToString
End If
Next intIndex
B) intMax = intValues0) For intIndex = 1 to intValues.length - 1
If intValuesintIndex) > intMax Then
IntMax = intValuesintIndex)
End If
Next
LblMaxValue.text = intMax.ToString
C) For intIndex = 0 To intNUM If intValuesintIndex) > intMax Then
IntValuesintIndex) = intMax
End If
Next
LblMaxValue.Text = intMax.ToString
D) intMax = intValues0) For intIndex = 1 To intValues.length
If intValuesintIndex) > intMax) Then
IntMax = intValuesintIndex)
LblMaxValue.Text = intMax.ToString
End If
Next
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
11
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.ShowintValuesintCount).ToString)
Next intCount
B) For intCount = 1 To IntValues.Length MessageBox.ShowintValuesintCount).ToString)
Next
C) For Each strElement As String In intValues MessageBox.ShowstrElement)
Next
D) For Each intNumber as Integer In intValues MessageBox.ShowintNumber.ToString)
Next
A) Dim intCount As Integer For intCount = 0 To intValues.Length - 1)
MessageBox.ShowintValuesintCount).ToString)
Next intCount
B) For intCount = 1 To IntValues.Length MessageBox.ShowintValuesintCount).ToString)
Next
C) For Each strElement As String In intValues MessageBox.ShowstrElement)
Next
D) For Each intNumber as Integer In intValues MessageBox.ShowintNumber.ToString)
Next
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
12
In the array declaration below, what is the significance of the number 7? Dim strNames7) 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
13
Which of the following statements sorts an array named intValues?
A) Sort.ArrayintValues)
B) SortintValues)
C) Sort.ArrayintValues))
D) Array.SortintValues)
A) Sort.ArrayintValues)
B) SortintValues)
C) Sort.ArrayintValues))
D) Array.SortintValues)
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
14
What is the error in the following code, and when will it be caught? Dim intValues5) As Integer
Dim intIndex As Integer
For intIndex = 0 To 10
IntValuesintIndex) = 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 out of bounds error will occur. The error will occur at run time.
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
IntValuesintIndex) = 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 out of bounds error will occur. The error will occur at run time.
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
15
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
16
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
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
17
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
18
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 strNamesintCount) = "Joe" Then
IntPosition = intCount
End If
Next
B) blnFound = True intCount = 0
Do While Not blnFound) And intCount < = strNames.Length - 1)
If strNamesintCount) = "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 strNamesintCount) = "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 strNamesintCount) = "Joe" Then
BlnFound = True
IntPosition = intCount
End If
Next
A) For intCount = 0 To strNames.length-1 If strNamesintCount) = "Joe" Then
IntPosition = intCount
End If
Next
B) blnFound = True intCount = 0
Do While Not blnFound) And intCount < = strNames.Length - 1)
If strNamesintCount) = "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 strNamesintCount) = "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 strNamesintCount) = "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
19
Which of the following statements defines a two-dimensional Integer array named intTwoDArray with 6 rows and 4 columns?
A) Dim intTwoDArray5, 3) As Integer
B) Dim intTwoDArray3, 5) As Integer
C) Dim intTwoDArray6, 4) As Integer
D) Dim intTwoDArray4, 6) As Integer
A) Dim intTwoDArray5, 3) As Integer
B) Dim intTwoDArray3, 5) As Integer
C) Dim intTwoDArray6, 4) As Integer
D) Dim intTwoDArray4, 6) As Integer
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
20
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
21
What does the following section of code do? Dim intCount as Integer
Dim intXXXX as Integer = intNumbers0)
For intCount = 1 to inNumbers.Length - 1)
If intNumbersintCount) > intXXXX Then
IntXXXX = intNumbersintCount)
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 = intNumbers0)
For intCount = 1 to inNumbers.Length - 1)
If intNumbersintCount) > intXXXX Then
IntXXXX = intNumbersintCount)
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 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
23
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
24
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
25
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
26
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
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
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 decWeeklySalesTotalintNumSalesmen - 1, 52 - 1) as Decimal
B) Dim decWeeklySalesTotalintNumSalesmen - 1, 52) as Decimal
C) Dim decWeeklySalesTotalintNumSalesmen - 1, 52 - 1)
D) Dim decWeeklySalesTotalintNumSalesmen, 52) as Decimal
A) Dim decWeeklySalesTotalintNumSalesmen - 1, 52 - 1) as Decimal
B) Dim decWeeklySalesTotalintNumSalesmen - 1, 52) as Decimal
C) Dim decWeeklySalesTotalintNumSalesmen - 1, 52 - 1)
D) Dim decWeeklySalesTotalintNumSalesmen, 52) as Decimal
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
29
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)
StrStudentNamesintCount) = "NONE"
Next intCount
B) Dim intCount as Integer For intCount = 0 to strStudentNames.Length - 1)
StrStudentNamesintCount) = "NONE"
Next intCount
C) Dim intCount as Integer For intCount = 0 to strStudentNames.Length)
StrStudentNamesintCount) = "NONE"
Next intCount
D) Dim intCount as Integer For intCount = 1 to strStudentNames.Length)
StrStudentNamesintCount) = "NONE"
Next intCount
A) Dim intCount as Integer For intCount = 1 to strStudentNames.Length - 1)
StrStudentNamesintCount) = "NONE"
Next intCount
B) Dim intCount as Integer For intCount = 0 to strStudentNames.Length - 1)
StrStudentNamesintCount) = "NONE"
Next intCount
C) Dim intCount as Integer For intCount = 0 to strStudentNames.Length)
StrStudentNamesintCount) = "NONE"
Next intCount
D) Dim intCount as Integer For intCount = 1 to strStudentNames.Length)
StrStudentNamesintCount) = "NONE"
Next intCount
Unlock Deck
Unlock for access to all 34 flashcards in this deck.
Unlock Deck
k this deck
30
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
31
What does the following section of code do? Dim intCount as Integer
Dim intXXXX as Integer = intNumbers0)
For intCount = 1 to inNumbers.Length - 1)
If intNumbersintCount) < intXXXX Then
IntXXXX = intNumbersintCount)
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 = intNumbers0)
For intCount = 1 to inNumbers.Length - 1)
If intNumbersintCount) < intXXXX Then
IntXXXX = intNumbersintCount)
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
32
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 ListOf String)
A) New lstNames As List Of String
B) lstNames As String Object
C) Dim lstNames As New String
D) Dim lstNames As New ListOf String)
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
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