Deck 7: Arrays
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
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
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/87
Play
Full screen (f)
Deck 7: Arrays
1
In the line of code
Function Sum(scores As Integer) As Integer
the pair of parentheses that follows scores can be removed.
Function Sum(scores As Integer) As Integer
the pair of parentheses that follows scores can be removed.
False
2
The statement
Dim newlist(10) As String
is used to declare an array where each element has the value 10.
Dim newlist(10) As String
is used to declare an array where each element has the value 10.
False
3
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.
False
4
The ReDim statement causes an array to lose its current contents unless the word ReDim is followed by the keyword
A) CInt
B) MyBase
C) Preserve
D) Add
A) CInt
B) MyBase
C) Preserve
D) Add
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
5
After an array has been declared, its type (but not its size) can be changed with a ReDim statement.
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
6
After the following Dim statement is executed, how many elements will the array myVar have?
Dim myVar(7) As Double
A) 0
B) 1
C) 8
D) 9
Dim myVar(7) As Double
A) 0
B) 1
C) 8
D) 9
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
7
What two names are displayed in the list box when the button is clicked on?
Dim krispies as String
Private Sub frmCereal_Load(...) Handles MyBase.Load
krispies(0) = "snap"
krispies(1) = "crackle"
krispies(2) = "pop"
End Sub
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
lstBox.Items.Add(krispies.Max)
lstBox.Items.Add(krispies.Last)
End Sub
A) crackle and pop
B) crackle and snap
C) snap and crackle
D) snap and pop
Dim krispies as String
Private Sub frmCereal_Load(...) Handles MyBase.Load
krispies(0) = "snap"
krispies(1) = "crackle"
krispies(2) = "pop"
End Sub
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
lstBox.Items.Add(krispies.Max)
lstBox.Items.Add(krispies.Last)
End Sub
A) crackle and pop
B) crackle and snap
C) snap and crackle
D) snap and pop
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
8
Either a For...Next loop or a For Each loop can be used to display every other value from an array in a list box.
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
9
What two numbers are displayed in the list box when the button is clicked on?
Dim nums as Integer
Private Sub frmNumbers_Load(...) Handles MyBase.Load
nums(0) = 5
nums(1) = 3
nums(2) = 4
End Sub
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
lstBox.Items.Add(nums.Average)
lstBox.Items.Add(nums.Max)
End Sub
A) 4 and 5
B) 4 and 4
C) 3 and 5
D) 3 and 4
Dim nums as Integer
Private Sub frmNumbers_Load(...) Handles MyBase.Load
nums(0) = 5
nums(1) = 3
nums(2) = 4
End Sub
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
lstBox.Items.Add(nums.Average)
lstBox.Items.Add(nums.Max)
End Sub
A) 4 and 5
B) 4 and 4
C) 3 and 5
D) 3 and 4
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
10
Which statement is true regarding the following Dim statement?
Dim states(49) As String, populations(49) As Double
A) It is invalid since more than one array is dimensioned by a single Dim statement.
B) It is invalid since the two arrays must have the same data type.
C) The subscripts of states range from 1 to 49.
D) The subscripts of populations range from 0 To 49.
Dim states(49) As String, populations(49) As Double
A) It is invalid since more than one array is dimensioned by a single Dim statement.
B) It is invalid since the two arrays must have the same data type.
C) The subscripts of states range from 1 to 49.
D) The subscripts of populations range from 0 To 49.
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
11
Like other variables, array variables can be declared and assigned initial values at the same time.
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
12
A Function procedure can return a number, but cannot return an array of numbers.
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
13
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) determine the largest value for each of the elements
B) determine the largest subscript in the array
C) determine the smallest value for each of the elements
D) declare a new array with the name Count
For index As Integer = 0 to (score.Count - 1)
the Count method is used to carry out which of the following tasks?
A) determine the largest value for each of the elements
B) determine the largest subscript in the array
C) determine the smallest value for each of the elements
D) declare a new array with the name Count
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
14
In the statement
Dim scores(30) As Double
the number 30 designates which of the following?
A) the highest value of the subscripts of the elements for the array scores
B) the maximum value that can be assigned to any element in the array scores
C) the data type for the array scores
D) the value initially assigned to each element in the array scores
Dim scores(30) As Double
the number 30 designates which of the following?
A) the highest value of the subscripts of the elements for the array scores
B) the maximum value that can be assigned to any element in the array scores
C) the data type for the array scores
D) the value initially assigned to each element in the array scores
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
15
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
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
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
16
In the line of code
Dim scores As Integer = {55, 33, 12}
the upper bound of the array scores is 12.
Dim scores As Integer = {55, 33, 12}
the upper bound of the array scores is 12.
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
17
An array can contain both numeric and string values.
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
18
What names are displayed in the list box when the button is clicked on?
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim names As String = IO.File.ReadAllLines("Data.txt")
lstBox.Items.Clear
For i As Integer = (names.Count - 1) To 0 Step -2
lstBox.Items.Add(names(i))
Next
End Sub
Assume the five lines of the file Data.txt contain the following entries: Bach, Borodin, Brahms, Beethoven, Britain.
A) Bach, Brahms, and Britain
B) Britain, Beethoven, Brahms, Borodin, and Bach
C) Bach, Borodin, Brahms, Beethoven, and Britain
D) Britain, Brahms, and Bach
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim names As String = IO.File.ReadAllLines("Data.txt")
lstBox.Items.Clear
For i As Integer = (names.Count - 1) To 0 Step -2
lstBox.Items.Add(names(i))
Next
End Sub
Assume the five lines of the file Data.txt contain the following entries: Bach, Borodin, Brahms, Beethoven, Britain.
A) Bach, Brahms, and Britain
B) Britain, Beethoven, Brahms, Borodin, and Bach
C) Bach, Borodin, Brahms, Beethoven, and Britain
D) Britain, Brahms, and Bach
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
19
Each individual variable in the list
student(0), student(1), student(2)
is known as a(n)
A) subscript.
B) dimension.
C) element.
D) type.
student(0), student(1), student(2)
is known as a(n)
A) subscript.
B) dimension.
C) element.
D) type.
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
20
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) 2
B) 1
C) 11
D) 0
Dim scores As Integer = {55, 33, 12}
the upper bound of the array scores is which of the following?
A) 2
B) 1
C) 11
D) 0
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
21
What is the output of the following program when the button is clicked on?
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim result As Double
Dim number(4) As Double
FillArray(number)
result = SumArray(number)
txtBox.Text = CStr(result)
End Sub
Sub FillArray(ByRef anyArray As Double)
Dim temp As String = IO.File.ReadAllLines("Data.txt")
For i As Integer = 0 To 4
anyArray(i) = CDbl(temp(i))
Next
End Sub
Function SumArray(anyArray As Double) As Double
Dim total As Double
total = 0
For i As Integer = 0 To 4 Step 2
total += anyArray(i)
Next
Return total
End Function
Assume the five rows of the file Data.txt contain the following entries: 1, 3, 5, 7, 9
A) 0
B) 25
C) 15
D) None of the above
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim result As Double
Dim number(4) As Double
FillArray(number)
result = SumArray(number)
txtBox.Text = CStr(result)
End Sub
Sub FillArray(ByRef anyArray As Double)
Dim temp As String = IO.File.ReadAllLines("Data.txt")
For i As Integer = 0 To 4
anyArray(i) = CDbl(temp(i))
Next
End Sub
Function SumArray(anyArray As Double) As Double
Dim total As Double
total = 0
For i As Integer = 0 To 4 Step 2
total += anyArray(i)
Next
Return total
End Function
Assume the five rows of the file Data.txt contain the following entries: 1, 3, 5, 7, 9
A) 0
B) 25
C) 15
D) None of the above
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
22
The following pair of statement is valid.
x = CInt(InputBox("Enter number of items (must be a positive integer)"))
ReDim myArray(x - 1)
x = CInt(InputBox("Enter number of items (must be a positive integer)"))
ReDim myArray(x - 1)
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
23
Given the Dim statement below, which set of statements will initialize all elements of myArray to 100?
Dim myArray(100) As Double
A) myArray = 100
B) For i As Integer = 0 To 100 (i) = 100 Next
C) For j As Integer = 0 to 100 myArray(j) = 100 Next
D) myArray is already initialized to 100 by the Dim statement.
Dim myArray(100) As Double
A) myArray = 100
B) For i As Integer = 0 To 100 (i) = 100 Next
C) For j As Integer = 0 to 100 myArray(j) = 100 Next
D) myArray is already initialized to 100 by the Dim statement.
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
24
What is the output of the following program segment?
Dim temp As String = IO.File.ReadAllLines("Data.txt")
Dim n As Integer = temp.Count - 1
Dim numbers(n) As Double, h As Double = 0
For i As Integer = 0 To n
numbers(i) = CDbl(temp(i))
Next
For k As Integer = 0 to n
h += numbers(k)
Next
txtBox.Text = CStr(h)
Assume the four rows of the file Data.txt contain the following entries: 2, 4, 2, 3
A) 11
B) 2
C) 7
D) 4
Dim temp As String = IO.File.ReadAllLines("Data.txt")
Dim n As Integer = temp.Count - 1
Dim numbers(n) As Double, h As Double = 0
For i As Integer = 0 To n
numbers(i) = CDbl(temp(i))
Next
For k As Integer = 0 to n
h += numbers(k)
Next
txtBox.Text = CStr(h)
Assume the four rows of the file Data.txt contain the following entries: 2, 4, 2, 3
A) 11
B) 2
C) 7
D) 4
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
25
If the following statement appears in a program, the array scores must have been declared using the String data type.
scores(1) = 87
scores(1) = 87
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
26
What names are displayed in the list box when the button is clicked on?
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim file As String = "Ships.txt"
Dim ships As String = FillArray(file)
lstBox.Items.Add(ships(2))
lstBox.Items.Add(ships.Min)
End Sub
Function FillArray(file As String) As String
Dim names As String = IO.File.ReadAllLines(file)
Return names
End Function
Assume the three lines of the file Ships.txt contain the following entries: Pinta, Nina, Santa Maria.
A) Pinta and Nina
B) Santa Maria and Pinta
C) Nina and Santa Maria
D) Santa Maria and Nina
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim file As String = "Ships.txt"
Dim ships As String = FillArray(file)
lstBox.Items.Add(ships(2))
lstBox.Items.Add(ships.Min)
End Sub
Function FillArray(file As String) As String
Dim names As String = IO.File.ReadAllLines(file)
Return names
End Function
Assume the three lines of the file Ships.txt contain the following entries: Pinta, Nina, Santa Maria.
A) Pinta and Nina
B) Santa Maria and Pinta
C) Nina and Santa Maria
D) Santa Maria and Nina
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
27
What numbers are displayed in the list box by the following program segment?
Dim numbers As Integer = {4, 7, 9, 3, 1, 9, 7}
Dim query = From number in numbers
Where number > 6
Select number
lstBox.Items.Add(query.Count)
lstBox.Items.Add(query.Average)
A) 7 and 12
B) 4 and 8
C) 2 and 12
D) 7 and 8
Dim numbers As Integer = {4, 7, 9, 3, 1, 9, 7}
Dim query = From number in numbers
Where number > 6
Select number
lstBox.Items.Add(query.Count)
lstBox.Items.Add(query.Average)
A) 7 and 12
B) 4 and 8
C) 2 and 12
D) 7 and 8
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
28
Consider the following Dim and assignment statements for myArray. The assignment statement will cause a "Subscript out of range" error.
Dim myArray(50) As
Double myArray(34) = 51
Dim myArray(50) As
Double myArray(34) = 51
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
29
What numbers are displayed in the list box when the button is clicked on?
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim file As String = "Beatles.txt"
Dim fabFour As String = FillArray(file)
lstBox.Items.Add(Array.IndexOf(fabFour, "Ringo")
lstBox.Items.Add(fabFour.Count - 1)
End Sub
Function FillArray(file As String) As String
Dim names As String = IO.File.ReadAllLines(file)
Return names
End Function
Assume the four lines of the file Beatles.txt contain the following entries: John, Paul, Ringo, George.
A) 3 and 3
B) 3 and 4
C) 2 and 3
D) 2 and 4
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim file As String = "Beatles.txt"
Dim fabFour As String = FillArray(file)
lstBox.Items.Add(Array.IndexOf(fabFour, "Ringo")
lstBox.Items.Add(fabFour.Count - 1)
End Sub
Function FillArray(file As String) As String
Dim names As String = IO.File.ReadAllLines(file)
Return names
End Function
Assume the four lines of the file Beatles.txt contain the following entries: John, Paul, Ringo, George.
A) 3 and 3
B) 3 and 4
C) 2 and 3
D) 2 and 4
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
30
Unless otherwise specified, Visual Basic assigns the value 0 to each element of a numeric array when it is declared with a Dim statement.
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
31
What is the output of the following program segment?
Dim c As Double
Dim temp As String = IO.File.ReadAllLines("Data1.txt")
Dim n As Integer = temp.Count - 1
Dim a(n) As Double
For i As Integer = 0 To n
a(i) = CDbl(temp(i))
Next
temp = IO.File.ReadAllLines("Data2.txt")
Dim b(n) As Double
For i As Integer = 0 To n
b(i) = CDbl(temp(i))
Next
For k As Integer = 0 To n
If a(k) = b(k) Then
c += 1
End If
Next
lstBox.Items.Add(c)
Assume the twenty rows of the file Data1.txt contain the following entries: 3, 2, 5, 1, 7, 8, 3, 5, 6, 2, 3, 6, 1, 6, 5, 5, 7, 2, 5, 3.
Assume the twenty rows of the file Data2.txt contain the following entries: 5, 3, 3, 4, 8, 2, 3, 5, 9, 5, 3, 7, 3, 7, 6, 3, 2, 1, 3, 4.
A) 2
B) 3
C) 4
D) 5
E) 6
Dim c As Double
Dim temp As String = IO.File.ReadAllLines("Data1.txt")
Dim n As Integer = temp.Count - 1
Dim a(n) As Double
For i As Integer = 0 To n
a(i) = CDbl(temp(i))
Next
temp = IO.File.ReadAllLines("Data2.txt")
Dim b(n) As Double
For i As Integer = 0 To n
b(i) = CDbl(temp(i))
Next
For k As Integer = 0 To n
If a(k) = b(k) Then
c += 1
End If
Next
lstBox.Items.Add(c)
Assume the twenty rows of the file Data1.txt contain the following entries: 3, 2, 5, 1, 7, 8, 3, 5, 6, 2, 3, 6, 1, 6, 5, 5, 7, 2, 5, 3.
Assume the twenty rows of the file Data2.txt contain the following entries: 5, 3, 3, 4, 8, 2, 3, 5, 9, 5, 3, 7, 3, 7, 6, 3, 2, 1, 3, 4.
A) 2
B) 3
C) 4
D) 5
E) 6
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
32
What states are displayed in the list box by the following program segment?
Dim states As String = {"Colorado", "New Mexico", "Arizona", "Utah"}
Dim query = From state in states
Where ContainsE(state)
Select state
For Each state in query
lstBox.Items.Add(state)
Next
Function ContainsE(word As String) As Boolean
If word.IndexOf("E") <> -1 Or word.IndexOf("e") <> -1 Then
Return True
Else
Return False
End If
End Function
A) Colorado
B) New Mexico
C) Colorado, New Mexico, Arizona, Utah
D) No states
Dim states As String = {"Colorado", "New Mexico", "Arizona", "Utah"}
Dim query = From state in states
Where ContainsE(state)
Select state
For Each state in query
lstBox.Items.Add(state)
Next
Function ContainsE(word As String) As Boolean
If word.IndexOf("E") <> -1 Or word.IndexOf("e") <> -1 Then
Return True
Else
Return False
End If
End Function
A) Colorado
B) New Mexico
C) Colorado, New Mexico, Arizona, Utah
D) No states
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
33
What names are displayed in the list box by the following program segment?
Dim newYork As String = "Manhatten,Bronx,Brooklyn,Queens,Staten Island"
Dim boroughs As String = newYork.Split(","c)
lstBox.Items.Add(boroughs(0))
lstBox.Items.Add(borought.Min)
A) Brooklyn and Queens
B) Manhatten and Staten Island
C) Bronx and Manhatten
D) Manhatten and Bronx
Dim newYork As String = "Manhatten,Bronx,Brooklyn,Queens,Staten Island"
Dim boroughs As String = newYork.Split(","c)
lstBox.Items.Add(boroughs(0))
lstBox.Items.Add(borought.Min)
A) Brooklyn and Queens
B) Manhatten and Staten Island
C) Bronx and Manhatten
D) Manhatten and Bronx
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
34
A fractional number such as 4.6 is not allowed as a subscript.
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
35
What numbers are displayed in the list box by the following program segment?
Dim numbers As Integer = {4, 7, 9, 3, 1, 7, 7}
Dim query = From number in numbers
Where number > 6
Select number
Distinct
lstBox.Items.Add(query.Count)
lstBox.Items.Add(query.Average)
A) 5 and 12
B) 2 and 12
C) 2 and 8
D) 5 and 8
Dim numbers As Integer = {4, 7, 9, 3, 1, 7, 7}
Dim query = From number in numbers
Where number > 6
Select number
Distinct
lstBox.Items.Add(query.Count)
lstBox.Items.Add(query.Average)
A) 5 and 12
B) 2 and 12
C) 2 and 8
D) 5 and 8
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
36
What is displayed in the message box by the following code?
Dim message As String
Dim teamNames As String = {"Packers", "Jets", "Seahawks"}
ReDim Preserve teamName(1)
message = teamNames(1)
MessageBox.Show(message)
A) Packers
B) Jets
C) Seahawks
D) 2
Dim message As String
Dim teamNames As String = {"Packers", "Jets", "Seahawks"}
ReDim Preserve teamName(1)
message = teamNames(1)
MessageBox.Show(message)
A) Packers
B) Jets
C) Seahawks
D) 2
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
37
What is the output of the following program segment?
Dim nums(8) As Integer
Dim total As Double = 0
For i As Integer = 0 To 8
nums(i) = i
Next
For k As Integer = 1 To 4
total += 10 ^ nums(k) Next txtBox.Text = CStr(total)
A) 10000
B) 11110
C) 1110
D) 0
Dim nums(8) As Integer
Dim total As Double = 0
For i As Integer = 0 To 8
nums(i) = i
Next
For k As Integer = 1 To 4
total += 10 ^ nums(k) Next txtBox.Text = CStr(total)
A) 10000
B) 11110
C) 1110
D) 0
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
38
What states are displayed in the list box by the following program segment?
Dim states As String = {"Colorado", "New Mexico", "Arizona", "Utah"}
Dim query = From state in states
Where state.length < 5
Select state.ToUpper
For Each state in query
lstBox.Items.Add(state)
Next
A) Utah
B) COLORADO, NEW MEXICO, ARIZONA, UTAH
C) UTAH
D) No states
Dim states As String = {"Colorado", "New Mexico", "Arizona", "Utah"}
Dim query = From state in states
Where state.length < 5
Select state.ToUpper
For Each state in query
lstBox.Items.Add(state)
Next
A) Utah
B) COLORADO, NEW MEXICO, ARIZONA, UTAH
C) UTAH
D) No states
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
39
What will be displayed when the following program segment is executed?
Dim temp As String = IO.File.ReadAllLines("Data.txt")
Dim n As Integer = temp.Count - 1
Dim a(n) As Double
For k As Integer = 0 To n
a(k) = CDbl(temp(i))
Next
txtBox.Text = CStr(a(3))
Assume the five rows of the file Data.txt contain the following entries: 3, 2, 5, 1, 4.
A) 1
B) 2
C) 3
D) 4
Dim temp As String = IO.File.ReadAllLines("Data.txt")
Dim n As Integer = temp.Count - 1
Dim a(n) As Double
For k As Integer = 0 To n
a(k) = CDbl(temp(i))
Next
txtBox.Text = CStr(a(3))
Assume the five rows of the file Data.txt contain the following entries: 3, 2, 5, 1, 4.
A) 1
B) 2
C) 3
D) 4
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
40
What numbers are displayed in the list box by the following program segment?
Dim numbers As String = "1492,1776,1945"
Dim temp As String = numbers.Split(","c)
Dim nums(2) As Integer
For i As Integer = 0 to 2
nums(i) = CInt(temp(i))
Next
lstBox.Items.Add(nums(1))
lstBox.Items.Add(nums.First)
A) 1776 and 1492
B) 1776 and 1776
C) 1492 and 1492
D) 1945 and 1492
Dim numbers As String = "1492,1776,1945"
Dim temp As String = numbers.Split(","c)
Dim nums(2) As Integer
For i As Integer = 0 to 2
nums(i) = CInt(temp(i))
Next
lstBox.Items.Add(nums(1))
lstBox.Items.Add(nums.First)
A) 1776 and 1492
B) 1776 and 1776
C) 1492 and 1492
D) 1945 and 1492
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
41
Which of the following is NOT an example of an ordered array?
A) years
B) cities
C) nbrhoods
D) nums
A) years
B) cities
C) nbrhoods
D) nums
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
42
What words are displayed in the list box by the following program segment?
Dim deadlySins As String = {"pride", "greed", "anger", "envy", "lust", "gluttony", "sloth"}
Dim query = From sin in deadlySins
Order By sin Ascending
Where sin.StartsWith("g")
Select sin
lstBox.Items.Add(query.First)
lstBox.Items.Add(query.Max)
A) gluttony and greed
B) gluttony and gluttony
C) pride and gluttony
D) greed and greed
Dim deadlySins As String = {"pride", "greed", "anger", "envy", "lust", "gluttony", "sloth"}
Dim query = From sin in deadlySins
Order By sin Ascending
Where sin.StartsWith("g")
Select sin
lstBox.Items.Add(query.First)
lstBox.Items.Add(query.Max)
A) gluttony and greed
B) gluttony and gluttony
C) pride and gluttony
D) greed and greed
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
43
Searching successive elements of an ordered list beginning with the first element is known as a binary search.
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
44
Suppose a structure is created with the code
Structure stateUSA
Dim capCity As String
Dim stateNum As Integer
End Structure
in the Declarations section of the Code window. The code
Dim stateWA As stateUSA Dim
message As String
stateWA.stateNum = 42
stateWA.capCity = "Olympia"
message = stateWA.capCity & " " & stateWA.stateNum
MessageBox.Show(message)
is placed in the Click event procedure for one of the program's buttons. What output will be displayed in the message box when the button is clicked on?
A) 42 Olympia
B) Olympia42
C) 42Olympia
D) Olympia 42
Structure stateUSA
Dim capCity As String
Dim stateNum As Integer
End Structure
in the Declarations section of the Code window. The code
Dim stateWA As stateUSA Dim
message As String
stateWA.stateNum = 42
stateWA.capCity = "Olympia"
message = stateWA.capCity & " " & stateWA.stateNum
MessageBox.Show(message)
is placed in the Click event procedure for one of the program's buttons. What output will be displayed in the message box when the button is clicked on?
A) 42 Olympia
B) Olympia42
C) 42Olympia
D) Olympia 42
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
45
What numbers are displayed in the list box by the following program segment?
Dim states As String = {"Colorado", "New Mexico", "Arizona", "Utah"}
Dim query = From state in states
Where state.EndsWith("o")
Select state.Length
For Each number in query
lstBox.Items.Add(number)
Next
A) 8 and 10
B) 8, 10, 7, 4
C) 8
D) 29
Dim states As String = {"Colorado", "New Mexico", "Arizona", "Utah"}
Dim query = From state in states
Where state.EndsWith("o")
Select state.Length
For Each number in query
lstBox.Items.Add(number)
Next
A) 8 and 10
B) 8, 10, 7, 4
C) 8
D) 29
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
46
What colleges are displayed in the list box by the following program segment?
Dim ivies As String = {"Harvard", "Princeton", "Yale", "Dartmouth", "Brown", "Columbia", "Univ. of PA", "Cornell"}
Dim query = From college in ivies
Order By college Descending
Select college
lstBox.Items.Add(query.First)
lstBox.Items.Add(query.Min)
A) Yale and Brown
B) Yale and Yale
C) Brown and Brown
D) Harvard and Brown
Dim ivies As String = {"Harvard", "Princeton", "Yale", "Dartmouth", "Brown", "Columbia", "Univ. of PA", "Cornell"}
Dim query = From college in ivies
Order By college Descending
Select college
lstBox.Items.Add(query.First)
lstBox.Items.Add(query.Min)
A) Yale and Brown
B) Yale and Yale
C) Brown and Brown
D) Harvard and Brown
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
47
What words are displayed in the list box by the following program segment?
Dim dimensions As String = {"width", "height", "depth"}
Dim query = From dimension in dimensions
Order By dimension.Length Descending, dimension Ascending
Select dimension
lstBox.DataSource = query.ToList
lstBox.SelectedIndex = Nothing
A) width, height, depth
B) height, depth, width
C) height, width, depth
D) depth, width, height
Dim dimensions As String = {"width", "height", "depth"}
Dim query = From dimension in dimensions
Order By dimension.Length Descending, dimension Ascending
Select dimension
lstBox.DataSource = query.ToList
lstBox.SelectedIndex = Nothing
A) width, height, depth
B) height, depth, width
C) height, width, depth
D) depth, width, height
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
48
What numbers are displayed in the list box by the following program segment?
Dim numbers As Double = {.5, 1, 2, 2.5}
Dim query = From number in numbers
Where number < 2
Let FormattedPer = number.ToString("P")
Select FormattedPer
For Each percent In query
lstBox.Items.Add(percent)
Next
A) .5 and 1
B) 50% and 100%
C) 50.00%, 100.00%, 200.00%, 250.00%
D) 50.00% and 100.00%
Dim numbers As Double = {.5, 1, 2, 2.5}
Dim query = From number in numbers
Where number < 2
Let FormattedPer = number.ToString("P")
Select FormattedPer
For Each percent In query
lstBox.Items.Add(percent)
Next
A) .5 and 1
B) 50% and 100%
C) 50.00%, 100.00%, 200.00%, 250.00%
D) 50.00% and 100.00%
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
49
What words are displayed in the list box by the following program segment?
Dim deadlySins As String = {"pride", "greed", "anger", "envy", "lust", "gluttony", "sloth"}
Dim query = From sin in deadlySins
Order By sin.Length Descending
Select sin.ToUpper
lstBox.Items.Add(query.First)
lstBox.Items.Add(query.Min)
A) GLUTTONY and GLUTTONY
B) GLUTTONY and SLOTH
C) GLUTTONY and ANGER
D) PRIDE and ENVY
Dim deadlySins As String = {"pride", "greed", "anger", "envy", "lust", "gluttony", "sloth"}
Dim query = From sin in deadlySins
Order By sin.Length Descending
Select sin.ToUpper
lstBox.Items.Add(query.First)
lstBox.Items.Add(query.Min)
A) GLUTTONY and GLUTTONY
B) GLUTTONY and SLOTH
C) GLUTTONY and ANGER
D) PRIDE and ENVY
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
50
Arrays are said to be ordered only if the values are in ascending order.
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
51
What years are displayed in the list box by the following program segment?
Dim years As Integer = {1492, 1776, 1840, 1929, 1945, 2005}
Dim query = From year in years
Where Is20thCentury(year)
Select year
For Each year in query
lstBox.Items.Add(year)
Next
Function Is20thCentury(num As Integer) As Boolean
If (num >= 1900) and (num < 2000) Then
Return True
Else
Return False
End IF
End Function
A) 1929 and 1945
B) 1929
C) 1492, 1776, 1840, 1929, 1945, 2005
D) No years
Dim years As Integer = {1492, 1776, 1840, 1929, 1945, 2005}
Dim query = From year in years
Where Is20thCentury(year)
Select year
For Each year in query
lstBox.Items.Add(year)
Next
Function Is20thCentury(num As Integer) As Boolean
If (num >= 1900) and (num < 2000) Then
Return True
Else
Return False
End IF
End Function
A) 1929 and 1945
B) 1929
C) 1492, 1776, 1840, 1929, 1945, 2005
D) No years
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
52
Consider the following structure definition. Which Dim statement would correctly declare an array of this structure for elements having subscripts from 0 through 30?
Structure carType Dim
yr As Integer Dim
make As String Dim
model As String
End Structure
A) You cannot have an array of structures.
B) Dim carType(30)
C) Dim car(30) As carType
D) Dim carType(30) As car
Structure carType Dim
yr As Integer Dim
make As String Dim
model As String
End Structure
A) You cannot have an array of structures.
B) Dim carType(30)
C) Dim car(30) As carType
D) Dim carType(30) As car
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
53
Suppose a structure is created with the code
Structure stateUSA
Dim capCity As String
Dim stateNum As Integer
End Structure
in the Declarations section of the Code Editor. Which of the following statements correctly declares a variable of type stateUSA?
A) Dim stateUSA As stateWA
B) Dim stateWA As Structure
C) Dim stateWA As stateUSA
D) Dim stateWA As Member
Structure stateUSA
Dim capCity As String
Dim stateNum As Integer
End Structure
in the Declarations section of the Code Editor. Which of the following statements correctly declares a variable of type stateUSA?
A) Dim stateUSA As stateWA
B) Dim stateWA As Structure
C) Dim stateWA As stateUSA
D) Dim stateWA As Member
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
54
What numbers are displayed in the list box by the following program segment?
Dim numbers As Integer = {5, 79, 8, 33, 27}
Dim query = From number in numbers
Let formattedNum = number.ToString("N0")
Order By formattedNum Ascending
Select formattedNum
lstBox.DataSource = query.ToList
lstBox.SelectedIndex = Nothing
A) 5, 8, 27, 33, 79
B) 79, 33, 27, 8, 5
C) 27, 33, 5, 79, 8
D) 5, 79, 8, 33, 27
Dim numbers As Integer = {5, 79, 8, 33, 27}
Dim query = From number in numbers
Let formattedNum = number.ToString("N0")
Order By formattedNum Ascending
Select formattedNum
lstBox.DataSource = query.ToList
lstBox.SelectedIndex = Nothing
A) 5, 8, 27, 33, 79
B) 79, 33, 27, 8, 5
C) 27, 33, 5, 79, 8
D) 5, 79, 8, 33, 27
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
55
What names are displayed in the list box by the following program segment?
Dim tonightShow As String = {"Allen", "Parr", "Carson", "Leno", "O'Brien", "Leno"}
Dim query = From host in tonightShow
Where host.Length = 4
Select host
Distinct
For Each host in query
lstBox.Items.Add(host)
Next
A) Parr, Leno, Leno
B) Parr, Leno
C) Leno
D) No names
Dim tonightShow As String = {"Allen", "Parr", "Carson", "Leno", "O'Brien", "Leno"}
Dim query = From host in tonightShow
Where host.Length = 4
Select host
Distinct
For Each host in query
lstBox.Items.Add(host)
Next
A) Parr, Leno, Leno
B) Parr, Leno
C) Leno
D) No names
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
56
In an ascending ordered array, the value of each element is
A) less than or equal to the value of the next element.
B) greater than or equal to the value of the next element.
C) equal to the value of the next element.
D) greater than the value of the next element.
A) less than or equal to the value of the next element.
B) greater than or equal to the value of the next element.
C) equal to the value of the next element.
D) greater than the value of the next element.
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
57
What states are displayed in the list box by the following program segment?
Dim states As String = {"Colorado", "New Mexico", "Arizona", "Utah"}
Dim query = From state in states
Order By state Ascending
Select state
lstBox.Items.Add(query.First)
lstBox.Items.Add(query.Min)
A) Arizona and Colorado
B) Arizona and Utah
C) Colorado and Arizona
D) Arizona and Arizona
Dim states As String = {"Colorado", "New Mexico", "Arizona", "Utah"}
Dim query = From state in states
Order By state Ascending
Select state
lstBox.Items.Add(query.First)
lstBox.Items.Add(query.Min)
A) Arizona and Colorado
B) Arizona and Utah
C) Colorado and Arizona
D) Arizona and Arizona
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
58
What colleges are displayed in the list box by the following program segment?
Dim ivies As String = {"Harvard", "Princeton", "Yale", "Dartmouth", "Brown", "Columbia", "Univ. of PA", "Cornell"}
Dim query = From college in ivies
Where college.Length <= 9
Order By college.Length Descending, college Ascending
Select college
lstBox.Items.Add(query.First)
lstBox.Items.Add(query.Max)
A) Dartmouth and Princeton
B) Yale and Brown
C) Yale and Cornell
D) Dartmouth and Yale
Dim ivies As String = {"Harvard", "Princeton", "Yale", "Dartmouth", "Brown", "Columbia", "Univ. of PA", "Cornell"}
Dim query = From college in ivies
Where college.Length <= 9
Order By college.Length Descending, college Ascending
Select college
lstBox.Items.Add(query.First)
lstBox.Items.Add(query.Max)
A) Dartmouth and Princeton
B) Yale and Brown
C) Yale and Cornell
D) Dartmouth and Yale
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
59
Consider the following Structure definition and declaration. Which assignment statement would correctly record that player number 13 had three home runs so far this season?
Structure playerType
Dim fullname As String
Dim team As String
Dim position As String
Dim homerun As Double
Dim average As Double
Dim rbi As Double
End Structure
Dim player(45) As playerType
A) player(13) = 3
B) player(13).homerun(3)
C) playerType(13).homerun = 3
D) player(13).homerun = 3
E) None of the above
Structure playerType
Dim fullname As String
Dim team As String
Dim position As String
Dim homerun As Double
Dim average As Double
Dim rbi As Double
End Structure
Dim player(45) As playerType
A) player(13) = 3
B) player(13).homerun(3)
C) playerType(13).homerun = 3
D) player(13).homerun = 3
E) None of the above
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
60
What colleges are displayed in the list box by the following program segment?
Dim ivies As String = {"Harvard", "Princeton", "Yale", "Dartmouth", "Brown", "Columbia", "Univ. of PA", "Cornell"}
Dim query = From college in ivies
Where college.Length <= 9
Order By college.Length Descending, college Descending
Select college
lstBox.Items.Add(query.Last)
lstBox.Items.Add(query.Min)
A) Dartmouth and Princeton
B) Yale and Brown
C) Yale and Cornell
D) Dartmouth and Yale
Dim ivies As String = {"Harvard", "Princeton", "Yale", "Dartmouth", "Brown", "Columbia", "Univ. of PA", "Cornell"}
Dim query = From college in ivies
Where college.Length <= 9
Order By college.Length Descending, college Descending
Select college
lstBox.Items.Add(query.Last)
lstBox.Items.Add(query.Min)
A) Dartmouth and Princeton
B) Yale and Brown
C) Yale and Cornell
D) Dartmouth and Yale
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
61
In the two-dimensional array declaration
Dim newVar(,) As Double = {{1, 2, 3}, {4, 5, 2054}, {6, 802, 2786}}
the comma in newVar(,) can be removed.
Dim newVar(,) As Double = {{1, 2, 3}, {4, 5, 2054}, {6, 802, 2786}}
the comma in newVar(,) can be removed.
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
62
The statement
Dim nextVar(3, 5) As Double
declares a two-dimensional array that can store a table containing 4 columns and 6 rows of numeric data.
Dim nextVar(3, 5) As Double
declares a two-dimensional array that can store a table containing 4 columns and 6 rows of numeric data.
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
63
Suppose a structure and an array are created with the code
Structure Nation
Dim name As String
Dim continent As String
Dim population As Double 'in millions
Dim area As Double 'in square miles
End Structure
Dim nations(191) As Nation in the Declarations section of the Code editor and the array is filled with data for the 192 member nations of the UN. What will be displayed in the DataGridView control when the following code is executed?
Dim query = From country In nations
Where (country.continent = "Europe") And
country.name.StartsWith("S")
Let countryUC = country.name.ToUpper
Let pop = (1000000 * country.population).ToString("N0")
Let area = (country.area).ToString("N0")
Order By countryUC Ascending
Select countryUC, pop, area
A) Three columns, with headers country, population, and area. The grid will display the countries in Europe (along with their populations and areas) whose names begin with the letter S. The countries will be displayed capitalized in alphabetical order and their populations and areas will be formatted with commas as thousands separators.
B) Four columns, with headers countryUC, continent, pop, and area. The grid will display the countries in Europe (along with their continents, populations and areas) whose names begin with the letter S. The countries will be displayed capitalized in alphabetical order and their populations and areas will be formatted with commas as thousands separators.
C) Three columns, with headers countryUC, pop, and area. The grid will display the countries in Europe (along with their populations and areas) whose names begin with the letter S. The countries will be displayed capitalized in alphabetical order and their populations and areas will be formatted with commas as thousands separators.
D) Three columns, with headers countryUC, pop, and area. The grid will display the countries in Europe (along with their populations and areas) whose names begin with the letter S. The countries will be displayed capitalized in reverse alphabetical order and their populations and areas will be formatted with commas as thousands separators.
Structure Nation
Dim name As String
Dim continent As String
Dim population As Double 'in millions
Dim area As Double 'in square miles
End Structure
Dim nations(191) As Nation in the Declarations section of the Code editor and the array is filled with data for the 192 member nations of the UN. What will be displayed in the DataGridView control when the following code is executed?
Dim query = From country In nations
Where (country.continent = "Europe") And
country.name.StartsWith("S")
Let countryUC = country.name.ToUpper
Let pop = (1000000 * country.population).ToString("N0")
Let area = (country.area).ToString("N0")
Order By countryUC Ascending
Select countryUC, pop, area
A) Three columns, with headers country, population, and area. The grid will display the countries in Europe (along with their populations and areas) whose names begin with the letter S. The countries will be displayed capitalized in alphabetical order and their populations and areas will be formatted with commas as thousands separators.
B) Four columns, with headers countryUC, continent, pop, and area. The grid will display the countries in Europe (along with their continents, populations and areas) whose names begin with the letter S. The countries will be displayed capitalized in alphabetical order and their populations and areas will be formatted with commas as thousands separators.
C) Three columns, with headers countryUC, pop, and area. The grid will display the countries in Europe (along with their populations and areas) whose names begin with the letter S. The countries will be displayed capitalized in alphabetical order and their populations and areas will be formatted with commas as thousands separators.
D) Three columns, with headers countryUC, pop, and area. The grid will display the countries in Europe (along with their populations and areas) whose names begin with the letter S. The countries will be displayed capitalized in reverse alphabetical order and their populations and areas will be formatted with commas as thousands separators.
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
64
Which of the following types of variables can only hold a single item of data?
A) two-dimensional arrays
B) simple variables
C) single-subscripted variables
D) double-subscripted variables
A) two-dimensional arrays
B) simple variables
C) single-subscripted variables
D) double-subscripted variables
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
65
Which of the following declarations creates a two-dimensional array?
A) Dim newVar(2, 2) As Double
B) Dim newVar As Integer
C) Dim newVar(2) As Double
D) Dim newVar(2)
A) Dim newVar(2, 2) As Double
B) Dim newVar As Integer
C) Dim newVar(2) As Double
D) Dim newVar(2)
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
66
Suppose a structure and an array are created with the code
Structure Nation
Dim name As String
Dim continent As String
Dim population As Double 'in millions
Dim area As Double 'in square miles
End Structure
Dim nations(191) As Nation
in the Declarations section of the Code editor and the array is filled with data for the 192 member nations of the UN. What will be displayed in the DataGridView control when the following code is executed?
Dim query = From country In nations
Where country.population > 200
Order By country.area Descending
Select country.name, country.continent
dgvNations.DataSource = query.ToList
dgvNations.CurrentCell = Nothing
A) Two columns, with headers name and continent. The grid will display the countries (along with their continents) whose populations are greater than 200 million people. The countries will be displayed in order to their population, beginning with the most populous country.
B) Four columns, with each row containing data about a single country whose population is greater than 200 million people. The countries will be displayed in order of their area, beginning with the largest country.
C) Two columns, with headers country.name and country.continent. The grid will display the countries (along with their continents) whose populations are greater than 200 million people. The countries will be displayed in order to their area, beginning with the largest country.
D) Two columns, with headers name and continent. The grid will display the countries (along with their continents) whose populations are greater than 200 million people. The countries will be displayed in order to their area, beginning with the largest country.
Structure Nation
Dim name As String
Dim continent As String
Dim population As Double 'in millions
Dim area As Double 'in square miles
End Structure
Dim nations(191) As Nation
in the Declarations section of the Code editor and the array is filled with data for the 192 member nations of the UN. What will be displayed in the DataGridView control when the following code is executed?
Dim query = From country In nations
Where country.population > 200
Order By country.area Descending
Select country.name, country.continent
dgvNations.DataSource = query.ToList
dgvNations.CurrentCell = Nothing
A) Two columns, with headers name and continent. The grid will display the countries (along with their continents) whose populations are greater than 200 million people. The countries will be displayed in order to their population, beginning with the most populous country.
B) Four columns, with each row containing data about a single country whose population is greater than 200 million people. The countries will be displayed in order of their area, beginning with the largest country.
C) Two columns, with headers country.name and country.continent. The grid will display the countries (along with their continents) whose populations are greater than 200 million people. The countries will be displayed in order to their area, beginning with the largest country.
D) Two columns, with headers name and continent. The grid will display the countries (along with their continents) whose populations are greater than 200 million people. The countries will be displayed in order to their area, beginning with the largest country.
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
67
Suppose a structure is created with the code
Structure stateUSA
Dim capCity As String
Dim yearFounded As Integer
End Structure
in the Declarations section of the Code window. In this structure, the variable capCity is known as a member.
Structure stateUSA
Dim capCity As String
Dim yearFounded As Integer
End Structure
in the Declarations section of the Code window. In this structure, the variable capCity is known as a member.
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
68
Suppose a structure is created with the code
Structure stateUSA
Dim capCity As String
Dim stateNum As Integer
End Structure
in the Declarations section of the Code window. The following statement correctly makes use of the stateNum member of this structure.
Structure stateUSA
Dim capCity As String
Dim stateNum As Integer
End Structure
in the Declarations section of the Code window. The following statement correctly makes use of the stateNum member of this structure.
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
69
Which of the following methods is used to change the words in a column header of a DataGridView control?
A) HeaderText
B) HeaderName
C) HeaderContent
D) HeaderCaption
A) HeaderText
B) HeaderName
C) HeaderContent
D) HeaderCaption
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
70
How many elements are in the array declared by
Dim myArray(3, 2) As Double
A) 12
B) 8
C) 6
D) 2
E) None of the above
Dim myArray(3, 2) As Double
A) 12
B) 8
C) 6
D) 2
E) None of the above
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
71
When a variable with a user-defined data type is passed to a procedure, the corresponding parameter in the Sub or Function statement must be declared to be of the same data type.
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
72
A two-dimensional array can be declared and initialized at the same time.
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
73
Suppose a structure and an array are created with the code
Structure Nation
Dim name As String
Dim continent As String
Dim population As Double 'in millions
Dim area As Double 'in square miles
End Structure
Dim nations(191) As Nation
in the Declarations section of the Code editor and the array is filled with data for the 192 member nations of the UN. What will be displayed in the list box when the following code is executed?
Dim query = From country In nations
Where country.continent = "Africa"
Order By country.population Descending
Select country.name
lstBox.DataSource = query.ToList
lstBox.SelectedIndex = Nothing
A) the names of the countries in Africa in alphabetical order
B) the names of the countries in Africa beginning with the name of the least populous country
C) the names of the countries in Africa beginning with the name of the most populous country
D) the names of the countries in Africa in reverse alphabetical order
Structure Nation
Dim name As String
Dim continent As String
Dim population As Double 'in millions
Dim area As Double 'in square miles
End Structure
Dim nations(191) As Nation
in the Declarations section of the Code editor and the array is filled with data for the 192 member nations of the UN. What will be displayed in the list box when the following code is executed?
Dim query = From country In nations
Where country.continent = "Africa"
Order By country.population Descending
Select country.name
lstBox.DataSource = query.ToList
lstBox.SelectedIndex = Nothing
A) the names of the countries in Africa in alphabetical order
B) the names of the countries in Africa beginning with the name of the least populous country
C) the names of the countries in Africa beginning with the name of the most populous country
D) the names of the countries in Africa in reverse alphabetical order
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
74
Which of the following types of variables is capable of holding the information contained in a table that has four rows and four columns?
A) one-dimensional arrays
B) simple variables
C) single-subscripted variables
D) double-subscripted variables
A) one-dimensional arrays
B) simple variables
C) single-subscripted variables
D) double-subscripted variables
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
75
Which of the following declarations can be used to create a three-dimensional array?
A) Dim newVar(3, 3) As Double
B) Dim newVar(2, 2, 2) As Double
C) Dim newVar(3) As Double
D) Dim newVar(3)
A) Dim newVar(3, 3) As Double
B) Dim newVar(2, 2, 2) As Double
C) Dim newVar(3) As Double
D) Dim newVar(3)
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
76
Given the following array, what value will be assigned to num?
A) 19
B) 4
C) 24
D) 0
E) None of the above
A) 19
B) 4
C) 24
D) 0
E) None of the above
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
77
Arrays that are capable of holding the contents of a table with several rows and columns, are known as two-dimensional arrays or double subscripted variables.
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
78
Suppose a structure and an array are created with the code
Structure Nation
Dim name As String
Dim continent As String
Dim population As Double 'in millions
Dim area As Double 'in square miles
End Structure
Dim nations(191) As Nation
in the Declarations section of the Code editor and the array is filled with data for the 192 member nations of the UN. What will be displayed in the list box when the following code is executed?
Dim query = From country In nations
Order By country.area Descending
Select country.name, country.population
lstBox.Items.Add(query.First.name)
lstBox.Items.Add(1000000 * query.First.population)
A) the name and population of the smallest country in the UN
B) the name and population of the largest country in the UN
C) the name and population of the least populous country in the UN
D) the name and population of the most populous country in the UN
Structure Nation
Dim name As String
Dim continent As String
Dim population As Double 'in millions
Dim area As Double 'in square miles
End Structure
Dim nations(191) As Nation
in the Declarations section of the Code editor and the array is filled with data for the 192 member nations of the UN. What will be displayed in the list box when the following code is executed?
Dim query = From country In nations
Order By country.area Descending
Select country.name, country.population
lstBox.Items.Add(query.First.name)
lstBox.Items.Add(1000000 * query.First.population)
A) the name and population of the smallest country in the UN
B) the name and population of the largest country in the UN
C) the name and population of the least populous country in the UN
D) the name and population of the most populous country in the UN
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
79
If the two-dimensional array nums has three rows and six columns, then the value of nums.GetUpperBound(0) is 3 and the value of nums.GetUpperBound(1) is 6.
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck
80
A structure can contain members that are simple variables only; members cannot be arrays.
Unlock Deck
Unlock for access to all 87 flashcards in this deck.
Unlock Deck
k this deck