practest2

advertisement
COSC 2409
Spring 2001
Practice Test 2
1.
The value of an argument in a Call statement can be changed by a Sub procedure only if the same
name is used in the Sub procedure's parameter list. (T/F)
2.
A user-defined function need not have parameters. (T/F)
3.
The following is a valid function call. (T/F)
Function1.Call
4.
The following statements are valid. (T/F)'
x = Val(InputBox("Enter number of items to be processed:"))
ReDim myArray(0 to x)
5.
When an End Sub statement is reached in a Sub procedure, execution jumps to
(A)
(B)
(C)
(D)
6.
Which one of the following is true about arguments and parameters?
(A)
(B)
(C)
(D)
7.
the statement before the Call statement which invoked the Sub procedure.
the statement after the Call statement which invoked the Sub procedure.
the beginning of the event procedure containing the Call statement.
the end of the event procedure containing the Call statement.
Arguments appear in Call statements; parameters appear in Sub statements.
Parameters appear in Call statements; arguments appear in Sub statements.
They are synonymous terms.
They are completely unrelated in a program.
What will be the output when the command button is clicked?
Private Sub cmdButton_Click()
Dim first As String, middle As String, last As String
first = "Augusta"
middle = "Ada"
last = "Byron"
Call Initials(first, middle, last)
End Sub
Private Sub Initials(c As String, b As String, a As String)
Dim theInitials As String
theInitials = Left(a, 1) & Left(b, 1) & Left(c, 1)
picBox.Print theInitials
End Sub
(A)
(B)
(C)
(D)
(E)
AAB
BAA
abc
ABA
None of the above
8.
What will be the output of the following program when the command button is clicked?
Private Sub cmdButton_Click()
Dim word1 As String, word2 As String, word3 As String
picBox.Cls
word1 = "First"
word2 = "Second"
word3 = "Third"
Call Myproc(word1, word2, word3)
End Sub
Private Sub Myproc(var3 As String, var2 As String, var1 As String)
picBox.Print var1; var2; var3
End Sub
(A)
(B)
(C)
(D)
9.
FirstSecondThird
ThirdSecondFirst
SecondThirdFirst
No output
What will be the output of the following program when the command button is clicked?
Private Sub cmdButton_Click()
Dim number As Single
picBox.Cls
number = 3
Call DoubleAndSquare(number)
picBox.Print number
End Sub
Private Sub DoubleAndSquare(myVar As Single)
myVar = myVar + myVar
myVar = myVar * myVar
End Sub
(A)
(B)
(C)
(D)
(E)
10.
3
36
6
0
9
Which of the following names would be best for the following Function (called NoName)?
Private Function NoName(number As Single) As Single
NoName = number ^ 3 + number ^ 3
End Function
(A)
(B)
(C)
(D)
11.
SquareAndCube
CubeAndDouble
CubeAndSquare
DoubleAndCube
Which statement is true regarding the following Dim statement?
Dim state(1 To 50) As String, population(1 To 50) As Single
(A)
(B)
(C)
(D)
It is invalid since more than one array is dimensioned by a single Dim statement.
The two arrays must have the same data type.
The range of state() is invalid.
The range of population() is 1 To 50.
12.
What is the output of the following program segment?
picBox.Cls
Dim num(0 To 9) As Integer, i As Integer, k As Integer, total As Integer
For i = 0 To 9
num(i) = i
Next i
total = 0
For k = 0 To 4
total = total + 10 ^ num(k)
Next k
picBox.Print total
(A)
(B)
(C)
(D)
(E)
13.
10000
11111
1111
0
1000
Given the Dim statement below, which array variable is NOT valid?
Dim myArray(0 to 35)
(A)
(B)
(C)
(D)
(E)
14.
myArray(35)
myArray(0)
myArray(18)
myArray(–35)
None of the above
What will be displayed when the following program segment is executed?
Dim a(4) As Single, k As Integer
Open "DATA.TXT" For Input As #1
For k = 0 To 4
Input #1, a(k)
Next k
Close #1
picBox.Cls
picBox.Print a(3)
Contents of DATA.TXT: 3, 2, 5, 1, 4
(A)
(B)
(C)
(D)
(E)
1
2
3
4
5
15.
What is the output of the following program segment?
Dim numbers(0 to 5) As Single, x As Single
Open "DATA.TXT" For Input As #1
Do While Not EOF(1)
Input #1, x
numbers(x) = numbers(x) + 2
Loop
Close #1
picBox.Cls
picBox.Print numbers(3)
Contents of DATA.TXT: 5, 3, 1, 3, 1, 3, 1
(A)
(B)
(C)
(D)
(E)
4
5
6
7
8
Download