IT 236 -- Practice Final -- July 12, 2005
Part A. Multiple Choice Questions. 5 points each. Give an optional reason for each question.
What is the VB.NET symbol for comment?
a. /*
b. //
c. <!--
d. '
How many times will this loop execute?
For x = 3 To 20 Step 5
WriteLine("Line " & x)
Next
a. 0
b. 4 c. 5
d. 17 e. 20
Which method call moves the focus to the TextBox control t?
a. t.Enter()
b. t.Focus() c.
t.MoveFocus() d.
t.Tab()
How do you bind the DataSet object ds to the DataGrid control
dg?
a. dg.DataBindings.Add(ds)
b. dg.DataSource = ds
c. ds.DataBindings.Add(dg)
d. ds.DataSource = dg
Which line sets the background color of the PictureBox control p to orange?
p.BackColor = Color.FromArgb(255, 128, 0)
p.bgColor = Color(255, 128, 0)
p.bgColor(Color.Orange)
p.SetBackColor(Color.Red,
Color.Yellow)
Part B. Problems. If you cannot give complete VB.Net code to solve the problem, explain what you do understand about the problem.
Construct the program trace and predict the output.
Public Sub Main()
Dim x As Integer = 5
Dim y As Integer
y = F(x \ 2 + 1) + 3
WriteLine(y + 4)
End Sub
Public Function F(s As Integer) As Integer
Dim t As Integer = 7
Dim u As Integer
If (s * t + 1) Mod 2 = 0 Then
u = s + 2 * t + 1
ElseIf
u = s + 3 * t + 1
End If
Return u + 1
End Sub
a. Write a function named BeginsAndEndsWithA that
returns True if the input string begins with A or a and ends with A or a.
It should return False otherwise.
b. Write a Main subroutine that
invokes your function.
The ComboBox control cb contains the abbreviations SUN
MON TUE WED THU FRI SAT. Write the event
handler cb_SelectedIndexChanged that will display a message box that will
display the day of the week corresponding to the selected abbreviation.
Repeat Problem 3, but look up the day of the week in the
DaysOfWeek table of the database weekdays.mdb.
DaysOfWeek Table | |
---|---|
Abbreviation | Name |
SUN | Sunday |
MON | Monday |
TUE | Tuesday |
WED | Wednesday |
THU | Thursday |
FRI | Friday |
SAT | Saturday |