What is the output of the following code

advertisement
What is the output of the following code?
Private Sub cmdDisplay_Click()
Dim str As String, o As Integer
str = Mid("Hello World", 5, 1)
Select Case str
Case Is > "s"
picOutput.Print "s"
Case Is <> 2
picOutput.Print "Not Two"
Case o
picOutput.Print "o"
Case "cs116" To "ph455"
picOutput.Print "graduated"
Case Else
picOutput.Print "Else"
End Select
End Sub
1. s
2. graduated
3. Else
4. o
5. Not Two
What is the output of the following code?
Private Sub cmdDisplay_Click()
Dim flag As Boolean
flag = False
Select Case flag
Case True
picOutput.Print "First";
Case False
picOutput.Print "Second";
Case Else
picOutput.Print "Third";
End Select
End Sub
1. First
2. First
Third
3. Third
4. Second
What is the output of the following code
Private Sub cmdDisplay_Click()
Dim month As Integer
x = 1
Do
Select Case (x / 2 - 2)
Case 0
Print x;
End Select
x = x + 1
Loop Until (x > 5)
End Sub
1. 1 2 3 4 5
2. 4
3. 0
4. 2
What is the output of the following code?
Private Sub cmdDisplay_Click()
Dim i As Integer
i = 10
For i = 2 To 9 Step 3
Select Case i
Case 1
Case Is > 5
output = output & "A"
Case 3 To 6
output = output & "B"
Case Else
output = output & "C"
End Select
Next i
Print output
End Sub
1. CBC
2. CBA
3. CAB
4. CBAB
How many stars (asterisks "*") will the following code print?
x = 1
Do While x <= 3
y = 0
Do Until y = x
Picture1.Print "*"
y = y + 1
Loop
x = x + 1
Loop
1. 3
2. 6
3. 10
4. 0
What is the output of the following code?
Do While x <= 10
x = x + 10
c = c + 1
Loop
Do Until x > 20
x = x * 2
c = c + 1
Loop
Picture1.Print x; c
1. 40
3
2. 20
2
3. 20
3
4. 40 2
Which one of the following code is an infinite loop?
1. Dim x as integer
Do Until x<>2
Loop
2. Dim x as integer, y as integer
x=10
y=0
Do While x + y = 10
x=x+1
y=y-1
Loop
3. Dim x as integer
Do
Loop while x <> 0
4. Dim x as integer
x=0
do
x=10
Loop Until x=10
What is the output of the following code?
x = 0
y = 0
Do While x > 10 Or y < 10
y = y + x
x = y
Loop
Print x; y
1. 11
11
2. Infinit loop
3. 0
4. 10
10
Which one of the following code has the correct syntax of "Do Loop Until"
structure?
0
x= 20
Do Loop
x=x-1
print x
Until x<10
1
x= 20
Loop
x=x-1
print x
Do Until x<10
2
x=20
Do
x=x-1
print x
Loop Until x<10
3
x=20
Do
x=x-1
print x
Loop Until
What is the output of the following code?
Assume the contents of S.txt are: 1.5, 4.2,9.7,3.8
Dim s As Single
Open "S.txt" For Input As #1
Do
Input #1, s
Loop Until EOF(1)
Input #1, s
Pic.Print s;
Close #1
1
3.8
2
1.5
3
1.5 4.2 9.7 3.8
4
Run-time error
What is the output of the following code?
Assume the contents of r1.txt are: 2,4,6
Dim r As Integer, m As Integer
m = 1
Open "r1.txt" For Input As #1
Do
Input #1, r
m = m * r
Loop While EOF(1)
Pic.Print m;
Close #1
1
2
2
8
3
48
4
24
What is the output of the following code?
For i = 1 To 4
For j = 1 To i
Pic1.Print j;
Next j
Pic1.Print
Next i
1. 1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
2. 1 2 3 4
1 2 3
1 2
1
3. 1
1 2
1 2 3
1 2 3 4
4. 4 3 2 1
3 2 1
2 1
1
5. 4 3 2 1
3 2
3
4
which of the following statements is true about the following code
For i = -7 To -3
pic1.Print i
Next i
1
This code will print numbers from -7 to -3 starting from -3
2
This code will print numbers from -7 to -3 starting from -7
3
This code will print all numbers less than -7
4
This code will print all numbers greater than
-7
which of the following statements is true about the following code
For i = 1 To 5.8
Step 1
pic1.Print i;
Next i
1
This code will print numbers from 1 to 6
2
This code will print numbers from 1 to 5
3
Run-time error
4
This code will print numbers from 1 to 5.8
What is the output of the following code:
For i = 1 To 6 Step 2
pic1.Print "*";
For j = 6 To 1 Step -2
pic1.Print "&";
Next i
Next j
1
Compile error
2
Run-time error
3
*&&&&*&&&&*&&&&*&&&&
4
&&&&*&&&&*&&&&*&&&&*
The preferred debugging method is?
1
Putting print statements in the code.
2
Examining the logfile.
3
Logical Testing.
4
Using a GUI debugger.
“Division by zero” is a?
1
logical Error
2
runtime error
3
compile error
4
All of the above
What is the output of the following code when the command button is clicked?
Private Sub cmdDisplay_Click()
Dim x As Integer, j As Integer
j = 0
For j = 2 To 4
Call Add1(j)
x = x + j
Next j
Print x
End Sub
Private Sub Add1(num As Integer)
num = num + 1
End Sub
1
8
2
9
3
6
4
10
What is the output of the following code when the command button is clicked?
Private Sub cmdDisplay_Click()
Dim a As Integer, b As Integer
a = 12
b = 6
Call Su1(a, b)
Call Su2(b, a)
Print a; b
End Sub
Private Sub Su1(x As Integer, y As Integer)
Print x + y;
End Sub
Private Sub Su2(x As Integer, y As Integer)
Print x - y;
End Sub
1
18 -6
12
6
2
18 -6
18 -6
3
18
6
12
6
4
18
6
18
6
What is the output of the following code when the command button is clicked?
Private Sub cmdDisplay_Click()
Dim b As Integer
b = 2
Call Mul(b)
Call Mul(b + 1)
Print b;
End Sub
Private Sub Mul(x As Integer)
Dim a As Integer
a = 5
Print a * x;
End Sub
1
10
15
2
2
15
10
5
3
10
15
15
4
10
15
10
5
15
10
6
What is the output of the following code when the command button is clicked?
Private Sub cmdDisplay_Click()
Dim a As Integer, b As Integer
a = 2
b = 4
Call Max(a, b)
Call Max(b, a)
End Sub
Private Sub Max(x As Integer, y As Integer)
If x > y Then
Print x
Else
Print y
End If
End Sub
1. 4
4
2. 2
2
3. 2
4
4. 4
2
Download