Exam
Name___________________________________
MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.
1) After the following Dim statement is executed, how many subscripted variables called myvar(i) will
1)
be available?
Dim myVar(7) As Double
A) 0
B) 1
C) 8
D) 9
Answer: C
2) What names are displayed in the list box when the button is clicked?
2)
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) Britain, Brahms, and Bach
B) Britain, Beethoven, Brahms, Borodin, and Bach
C) Bach, Borodin, Brahms, Beethoven, and Britain
D) Bach, Brahms, and Britain
Answer: A
3) What is the output of the following program segment?
3)
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) 4
D) 7
Answer: A
1