Multiple Choice Questions (xx points)

advertisement
CSC110 – Practice exam 1
Multiple Choice Questions
Answer all of the following questions. READ EACH QUESTION
CAREFULLY. Fill the correct bubble on your scantron sheet.
Each correct answer is worth 1 point. Each question has
EXACTLY one correct answer.
(1) Which of the following statements about functions and subs is NOT
true?
(A)
(B)
(C)
(D)
(E)
A sub procedure is a procedure that performs actions.
A function procedure is a procedure that performs actions.
A sub procedure returns a value to the point from which it was called.
A function procedure returns a value to the point from which it was called.
A function procedure can be called several times during the execution of a program
(2) Which of the following is the correct way to assign a font to a label using
common dialog boxes?
(A)
(B)
(C)
(D)
(E)
lblEmployee.Font = dlgFont.Font
dlgFont.Font = lblEmployee.Font
lblEmployee.Font And dlgFont.Font
dlgFont.Font = lblEmployee.Font
None of the above
(3) When is the counter incremented in a For/Next statement?
(A)
(B)
(C)
(D)
(A)
In the Next statement.
In the For statement.
In the Exit For statement.
Whenever the user clicks the mouse.
When the statements in the loop are executed.
CSC110 – Practice exam 2
(4) How many times will the statements inside this For/Next loop be
executed?
For intCount = 2 to 12 Step 3
'Statements in the loop
Next intCount
(A)
(B)
(C)
(D)
(E)
2
3
4
5
10
(5) What will be the value of intValue after execution of these statements?
intValue = 0
For intIndex = 1 to 10 Step 2
intValue += intIndex
Next intIndex
(A)
(B)
(C)
(D)
(E)
30
20
25
36
None of the above
(6) The statements inside of a Do/Loop may never be executed if
(A)
(B)
(C)
(D)
(E)
a Do Until statement is used at the top of the loop
a Loop Until statement is used at the bottom of the loop.
a Loop While statement is used at the bottom of the loop.
a Do Not statement is used at the top of the loop
The statements contain an If Then/Else statement
CSC110 – Practice exam 3
(7) What is printed by the following piece of code
For intCount1 = 1 To 4
For intCount2 = 1 To intCount1
Console.Write(“*”)
Next intCount2
Console.WriteLine()
Next intCount1
(A)
(B)
a line of *
a triangle of * with the shape of
(C)
a triangle of * with the shape of
(D)
a triangle of * with the shape of
(E)
a triangle of * with the shape of
(8) Consider the following code fragment
Dim strText As String
strText = ""
For intCount =0 To txtInput.Text.Length - 1
Dim c As Char = txtInput.Text.Chars(intCount)
If Char.IsLetter(c) Then
strText &= c
End If
Next intCount
Console.WriteLine(strText) 'line A
If the user types One1Two2 in the text box txtInput, what is printed by
the statement on line A once the above piece of code is executed?
(A)
(B)
(C)
(D)
(E)
ONETWO
OneTwo
One1Two2
12
None of the above since there is an error in the program
CSC110 – Practice exam 4
(9) If an array is declared as
Dim decSomeArray(10) As Decimal
Which of the following statements is true?
(A)
(B)
(C)
(D)
(E)
the elements of the array must be of type Double
there are exactly 11 elements in the array
the higher index value in the array is 9
one of the array elements could hold a string and another an integer
the lower index value in the array is 1
(10) A program contains the instruction:
x(y)
Which of the following is true?
(A)
(B)
(C)
(D)
(E)
x cannot be the name of an array
x cannot be a function
if y is an integer then x must be an array
The above statement should be written x[y]
if x is an array then y must be an integer
CSC110 – Practice exam 5
(11) Consider the following code fragment
Dim intA(5) As Integer
Dim intVal As Integer = 3
intA (1) = 0
intA (2) = 2
intA (3) = 4
intA (4) = 6
For intCount=4 To 1 Step -1
If intA (intCount) > intVal Then
intA (intCount + 1) = intA(intCount)
Else
Exit For
Endif
Next intCount
intA(intCount) = intVal
(12) What is the value of intA(3) when the above piece of code has been
executed
(A)
(B)
(C)
(D)
(E)
0
2
3
4
6
CSC110 – Practice exam 6
(13) What is the value of intMystery when the following statements are
executed?
Dim intNum as Integer = 10
Dim intMystery as Integer
If intNum Mod 2 =
intMystery =
Else If intNum <=
intMystery =
Else
intMystery =
End If
(A)
(B)
(C)
(D)
(E)
1 And intNum <= 9 Then
intNum
10
intNum + 1 * 2
intNum * 2 + 1
10
12
21
22
30
(14) List box and combo box controls have a(n) ____________ property
which can be used to get or set the content of the list.
(A)
(B)
(C)
(D)
(E)
Items
Values
Data
Variables
Indices
(15) What is the value of the SelectedIndex property if the user has NOT
selected an item from the list or combo box?
(A)
(B)
(C)
(D)
(E)
-1
0
1
"Empty"
"Null"
CSC110 – Practice exam 7
(16) What is printed by the following statement ?
Console.WriteLine( blnEqual("stanley","yelnats") )
where the function blnEqual is
Private Function blnEqual(s1 As String,s2 As
String) As Boolean
If s1.Length <> s2.Length Then
Return False
End If
Dim intCount As Integer
For intCount = 0 To s1.Length – 1
Dim c1 As Char = s1.Chars(intCount)
Dim c2 As Char = s2.Chars(s2.Length – intCount – 1)
If c2 <> c1 Then
Return False
End If
Next
Return True
End Function
(A)
(B)
(C)
(D)
(E)
True
False
stanley
yelnats
None of the above since there is an error in the code
CSC110 – Practice exam 8
(17) Consider the following code fragment:
Dim i As Integer
Dim j As Integer
i = 10
j = 10
Do while i<10
i = i+1
Loop
do
j = j + 1
Loop While j<10
Console.WriteLine(i & “ “ & j)
'line A
What is the output of the Print statement on line A
(A)
(B)
(C)
(D)
(E)
10
10
10
11
11
10
11
11
None of the above
Download