Visual Basic - Test 2
No. of Questions - 20
Time - 40 Minutes
Negative Marking- No

 

Answers

Question 1. Which type of argument allows you to provide an arbitrary number of arguments?

A.  Named
B.  ParamArray
C.  Optional
D.  ByRef

Question 2. You are creating an ActiveX component to be downloaded from your website. How can you prevent browsers from receiving a warning message when downloading your component?

A.  Save your control as Read-only
B.  Obtain a public key from Verisign.
C.  Reference your component using the OBJECT tag in your HTML page.
D.  Digitally sign your component

Question 3.

You have created an application that you are distributing over the Internet. After running the Setup Wizard, where can you find digital signatures?


A.  in the Primary.CAB file
B.  in the Secondary.CAB file
C.  in the Vb5dep.ini file
D.  in the Setup.lst file

Question 4. You have suspended execution while in the Form_Load event. What two actions can you perform in the Immediate Window while in suspend mode? (Choose two)

A.  Execute an ActiveX component
B.  Change the value of a variable
C.  Execute a private function of a standard module
D.  Change the value of a property.
Question 5. Which VB command would you use after this code to ensure that all records are processed?

Do While Data1.Recordset.EOF = False
Data1.Recordset.MoveNext
‘Process current record

A.  End Do
B.  FindNext
C.  Loop
D.  While End

Question 6. Examine this code:

[General Declarations]

Public Total As Integer
Function Running Total(AddMe)
Static Total
Total = Total + AddMe
RunningTotal = Total
End Function

Private Sub Form_Load()
Total = 5
End Sub

Private Sub cmdSum_Click()
MsgBox Running Total(1)
End Sub

What will the message box display after the user clicks the cmdSum button three times?


A.  1
B.  3
C.  5
D.  8

Question 7. Which two things can you do to access all loaded forms in a running application? (Choose two)

A.  Declare a form variable
B.  Use the For Each construct to loop through the forms.
C.  Declare a Forms Collection
D.  Call the AccessNextWindow() API function.
Question 8. How can you create a read-only object property.

A.  Omit the Property Let procedure
B.  Omit the Property Set procedure
C.  Preface the object property declaration with the "Private" keyboard.
D.  Set its ReadOnly property to True.

Question 9. Examine this code:

Sub FooBar(ByReg x As Integer, ByRef y As Integer)
x = 1
y = 2
End Sub

Sub Main
Dim z As Integer
FooBar z, z
End Sub

An erroneous setting for which compiler option could cause this code to execute incorrectly?

A.  Optimize for Fast Code
B.  Favor Pentium Pro
C.  Assume No Aliasing
D.  Remove Integer-Overflow Checks

Question 10. Why does this code cause an error?

Dim col As Collection
Set col = Forms
Which technique would you use to implement this design?

A.  "col" is a keyword.
B.  The Collection class and the Forms collection are not polymorphic
C.  A Collection is an ActiveX control and a Forms collection is an OLE control
D.  A Collection is not an object

 

Question 11. When should you use public variables instead of property procedures for read-write properties?

A.  The property has a well-defined set of values that need to be validated.
B.  The property is read-only.
C.  The property is a String data type, and there is no constraint on the size or value of the string.
D.  Setting the property causes changes to other internal variables or to the values of other properties.

Question 12.

How can you prevent a form’s QueryUnload event from executing?

A.  Hit the Escape key
B.  Click a window’s Close button.
C.  Execute the Unload statement.
D.  Execute the End statement.

Question 13. What can you manipulate to expand a TreeView control?

A.  TreeView Collection Items
B.  Node Objects
C.  ListView Items
D.  ImageList Controls

Question 14. Which code will remove the first control from a Controls collection named ctlMyControls?

A.  ctlMyControls.Remove Controls(1)
B.  Unload ctlMyControls(1)
C.  Set ctlMyControls(1) = Nothing
D.  Set ctlMyControls(1) = Null

Question 15. Where would you place this code to sort based on which column header the user clicks?

IvwDB.SortKey = ColumnHeader.index – 1
‘ Set Sorted to True to sort the list
IvwDB.Sorted = True

A.  ListView’s Click Event
B.  ListView’s ColumnClickEvent
C.  ListView’s NodeClick Event
D.  ListView’s ColumnChangeEvent

Question 16.

Which function can the Setup Wizard of the Enterprise Edition of VB 5 perform in addition to installing your ActiveX EXE project?

A.  Registers your project concurrently as a stand-alone application and as a shared component
B.  Reads your Setup.lst file to create your ActiveX project’s .dep file
C.  Installs your project as both a DCOM and a CORBA application
D.  Install your project as an ActiveX shared component

Question 17. Which technique should you use to report errors that occur in class modules in order to provide the most information?

A.  Use default Visual Basic error handling
B.  Use a central error handling routine
C.  Use the On Error statement
D.  Use the Err.Raise method

Question 18. Examine this code:

Private Sub Form_Load()
StatusBar1.Panels.Add
With StatusBar1.Panels
.Item(1).Style = sbrNum ‘Number lock
.Item(2).Style = sbrTime ‘Caps lock
End with
End Sub

Private Sub Status bar1_Click()
With StatusBar1
If.Style = sbrNormal Then
.Simple Text = "Date and Time: " & Now
.Style = sbrSimple ‘ Simple style
Else
.Style = sbrNormal ‘ Normal style
End If
End With
End Sub

What will the StatusBar StatusBar1 display if the user clicks it twice?

A.  two panels, one displaying the state of the NumLock key and the other the Time
B.  one panel displaying the state of the NumLock key
C.  one panel displaying the Time
D.  one panel displaying the Date and Time

Question 19. For which control does the ImageList control act as a central repository of images?


A.  ListImage
B.  TreeView
C.  ListView
D.  TabStrip

Question 20. This code is found in the Click event of a button named Command1 on Form1:

Private Sub Command1_Click( )
Call Form2.MySub
End Sub

In which two locations might you find the source code for the MySub procedure? (Choose two)

A.  general procedure of a general module
B.  general procedure of Form2
C.  event procedure of Form1
D.  event procedure of Form2

    scores