1. After the following Dim statement is executed, how many subscripted variables
ID: 638657 • Letter: 1
Question
1. After the following Dim statement is executed, how many subscripted variables called myvar(i) will be available?
Dim myVar(7) As Double
a. 0
b. 1
c. 8
d. 9
2. What names are displayed in the list box when the button is clicked?
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim name(4) As String
Dim sr As IO.StreamReader = IO.File.OpenText("DATA.TXT")
For i As Integer = 0 To 4
name(i) = sr.ReadLine
Next
sr.Close()
lstBox.Items.Clear()
For i As Integer = 4 To 0 Step -2
lstBox.Items.Add(name(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
3. What will be the value of phrase(1) after the following code is executed?
Dim place, i As Integer
Dim character, sentence, phrase(9) As String
sentence = "Every path hath a puddle."
place = 0
i = 0
character = sentence.Substring(place, 1)
Do
If character = " " Then
phrase(i) = sentence.Substring(0, place)
i += 1
End If
place += 1
character = sentence.Substring(place, 1)
Loop Until character = "."
a. Every
b. Every path
c. Every path hath
d. Every path hath a
4. What is the output of the following program segment?
Dim numbers(3) As Double, h As Double = 0
Dim sr As IO.StreamReader = IO.File.OpenText("DATA.TXT")
For i As Integer = 0 To 3
numbers(i) = CDbl(sr.ReadLine)
Next
sr.Close()
For k As Integer = 0 to 3
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
5. What is the output of the following program segment?
Dim numbers(4) As Double
Dim sr As IO.StreamReader = IO.File.OpenText("DATA.TXT")
For i As Integer = 0 To 4
numbers(i) = CDbl(sr.ReadLine)
Next
sr.Close()
For k As Integer = 0 To 2
numbers(k + 1) += numbers(k)
Next
txtBox.Text = CStr(numbers(3))
Assume the five rows of the file DATA.TXT contain the following entries: 3, 6, 4, 8, 3.
a. 10
b. 21
c. 18
d. 11
6. What is the output of the following program segment?
Dim myArray(4) As Double, num, k As Integer
Dim sr As IO.StreamReader = IO.File.OpenText("DATA.TXT")
For i As Integer = 0 To 4
myArray(i) = CDbl(sr.ReadLine)
Next
num = CInt(sr.ReadLine)
sr.Close()
k = 0
Do While (num > myArray(k)) And (k <= 4)
k += 1
Loop
txtBox.Text = CStr(k)
Assume the six rows of the file DATA.TXT contain the following entries: 2, 4, 6, 8, 10, 3.
a. 1
b. 2
c. 3
d. 4
7. What is the output of the following program segment?
Dim antonym(7) As String
Dim sr As IO.StreamReader = IO.File.OpenText("DATA.TXT")
For i As Integer = 0 To 6 Step 2
antonym(i) = sr.ReadLine
antonym(i + 1) = sr.ReadLine
Next
sr.Close()
txtBox.Text = antonym(3)
Assume the twelve rows of the file DATA.TXT contain the following entries: big, small, black, white, old, young, fast, slow, tall, short, hard, soft.
a. black
b. white
c. small
d. Subscript out of range
8. What is displayed in the list box by the following program segment?
Dim phoneDir(50) As String, i As Integer
Dim sr As IO.StreamReader = IO.File.OpenText("DATA.TXT")
For j As Integer = 0 To 9 Step 3
phoneDir(j) = sr.ReadLine
phoneDir(j + 1) = sr.ReadLine
phoneDir(j + 2) = sr.ReadLine
Next
sr.Close()
lstBox.Items.Clear()
i = 1
Do While phoneDir(i) <> ""
lstBox.Items.Add(phoneDir(i))
i += 3
Loop
Assume the twelve rows of the file DATA.TXT contain the following entries: Fischer, John, 797-3456, Robinson, Max, 535-8657, Stanberg, Jennifer, 544-9080, Thompson, Meg, 436-2345.
a. Fischer, Robinson, Stanberg, and Thompson
b. John, Max, Jennifer, and Meg
c. 797-3456, 535-8657, 544-9080, and 436-2345
d. No output
9. 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
10. In the statement: Dim score(3) As Double, the number 30 designates which of the following?
a. the highest value of the subscripts of the elements for the array score( ).
b. the maximum value that can be assigned to any element in the array score( ).
c. the data type for the array score( ).
d. the value initially assigned to each element in the array score( ).
11. In the line of code: For index = 0 to score.GetUpperBound(0), the method GetUpperBound(0) 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. Declares a new array with the name GetUpperBound
12. What is displayed in the message box by the following code?
Dim message As String
Dim teamName() As String = {"Packers", "Jets", "Seahawks"}
ReDim Preserve teamName(1)
message = teamName(1)
MessageBox.Show(message)
a. Packers
b. Jets
c. Seahawks
d. 2
13. What is the output of the following program when the button is clicked?
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 sr As IO.StreamReader = IO.File.OpenText("DATA.TXT")
For i As Integer = 0 To 4
anyArray(i) = CDbl(sr.ReadLine)
Next
sr.Close()
End Sub
Function SumArray(ByVal 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 choices apply.
14. What is the value of j after the following code segment has been executed?
Dim state(49) As String, j as Integer
'Assume that the data file STATES.TXT contains
'the names of the 50 states of the United States
'in the order they were admitted to the union.
Dim sr As IO.StreamReader = IO.File.OpenText("STATES.TXT")
j = 0
Do While sr.Peek <> -1
state(j) = sr.ReadLine
j += 1
Loop
sr.Close()
For i As Integer = 0 to state.GetUpperBound(0)
lstBox.Items.Add( "State Number " & i + 1 & " is " & state(i))
Next
a. 48
b. 49
c. 50
d. Unable to determine
15. 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
16. Which of the following is not an example of an ordered array?
a. (A) years()
1877
1944
2011
4301
b. (B) cities()
Selah
Wapato
Yakima
Zillah
c. (C) nbrhoods()
Hockinson
Brush Prairie
Dollars Corner
Battle Ground
d. (D) num()
457
457
457
458
17. Which of the following arrays could be searched most efficiently?
a. (A) years()
4301
1944
2011
4445
b. (B) cities()
Selah
Wapato
Yakima
Zillah
c. (C) nbrhoods()
Hockinson
Brush Prairie
Dollars Corner
Battle Ground
d. (D) num()
459
457
457
459
18. In an ordered array declared with the statement below, the value of the element namfriend(0) is equal to that of which of the other following elements?
a. namfriend(1)
b. namfriend(2)
c. namfriend(3)
d. namfriend(4)
19. A program contains the lines:
Select Case list1(m)
Case Is < list2(n)
newlist(r) = list1(m)
In this section of the program, the value of the mth element of the array list1( ) will be added into the array newlist( ) if which of the following is true?
a. the nth element of list2( ) is less than the mth element of list1( )
b. the nth element of list2( ) is greater than the mth element of list1( )
c. the nth element of list2( ) is equal to the mth element of list1( )
d. the mth element of list1( ) is greater than the nth element of list2( )
20. In the line of code:
Dim score() As Integer = {55, 33, 12}
the upper bound of the array score( ) is which of the following?
a. 2
b. 1
c. 11
d. 0
21. At times, you will encounter situations where some of the variables in an application are related to each other.
a. True
b. False
22. In the cases when you encounter situations where some variables are related, it is easier and more efficient to treat the related variables separately.
a. True
b. False
23. The most commonly used arrays in business applications are three-dimensional.
a. True
b. False
24. Each variable in an array has the same name and data type.
a. True
b. False
25. Superscripts are assigned by the computer when an array is created in internal memory.
a. True
b. False
26. To refer to the first variable in a one-dimensional String array named strFriends, you use strFriends(0)
1877
1944
2011
4301
Explanation / Answer
1)a
2)c
3)d
4)c
5)b
6)d
7)c
8)a
9)a
10)d
11)a
12)b
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.