PROG Quiz
PROG Quiz
PROG Quiz
Multiple Choice
Identify the letter of the choice that best completes the statement or answers the question.
Chapter1
1. All of the following are major hardware components of a typical computer system except
a. Main Memory c. Operating System
b. CPU d. secondary storage
11. How would you get the Design window to display if it is not visible in your project?
a. Press Shift+F9 on the keyboard.
1
b. Click View on the menu bar, and then on the View menu click Designer.
c. Double click the icon in the tool bar for the designer window.
d. Select view designer in the edit menu.
19. You want to find the perimeter of a rectangular room whose sides are represented by dblLength and
dblWidth. The statement to find the perimeter of this room is ________________. (The * means
multiplication)
a. dblPerimeter = dblLength x dblWidth c. dblPerimeter = 2 * dblLength + 2 * dblWidth
b. dblPerimeter = 2 * dblLength d. dblPerimeter = dblLength + dblWidth
2
a. programmer preference. c. classes, actions, and disciplines.
b. projects, solutions, and procedures. d. properties, methods, and events.
22. Which is considered a valid step for developing a Visual Basic application?
a. Make a list of methods needed for each c. Create a flowchart or pseudocode
control. version of each method.
b. Make a list of the controls needed. d. all of the above
23. What is the code used to display the words “Visual Basic” in a label named lblTitle?
a. lblTitle.Name = “Visual Basic” c. lblTitle.Text = “Visual Basic”
b. titleLabel.Name.Visual Basic d. “Visual Basic” = lblLabel.Text
26. If you want to display text which cannot be modified by the user, use the
a. TextBox control. c. Caption control.
b. Label control. d. Name control.
Chapter 2
29. The properties of the controls are listed
a. in the options window.
b. in the properties window.
c. solution explorer window.
d. in the project window.
30. When you select an existing control on a form during design time
a. its color changes to dark blue.
b. the sizing handles appear.
c. the tool box will be visible.
d. the project will automatically be saved.
31. If a label control is not wide enough for the text that is written into that control, then
a. only the text that fits into the label will appear.
b. the text that does not fit will be truncated.
c. the extra text is wrapped onto the next line or lines.
d. the label will expand to fit the text.
32. This is a transparent rectangular area that defines the control’s size.
a. bounding box
b. limiting region
c. size mode region
d. bounding region
3
33. All of the following steps allow you to delete a control from a form except
a. select the control, and then use the cut option on the menu bar.
b. Select the control, then click on the delete icon in the menu bar.
c. Select the control, then hit the delete key.
d. Select the control, then select delete from the edit menu.
34. This property is used to automatically adjust an image to fit the size of the PictureBox control it is
displayed in.
a. AutoSize
b. AutoAdjust
c. SizeAdjust
d. SizeMode
35. You save a Visual Basic .NET project in all of the following ways except
a. Click File on the menu bar, and then click Save All on the File menu.
b. Press Ctrl+Shift+S on the keyboard.
c. Click the Save Project button on the standard toolbar.
d. Click the Save All button on the standard toolbar.
36. You can end an application that is running in Visual Basic .NET in all of the following ways except
a. Click the down arrow on the Debug list box, and then click on release.
b. Click the close button on the applications window.
c. Click Debug on the menu bar, and then click Stop Debugging on the Debug menu.
d. Double click the Stop Debugging Icon on the extended Tool Bar while the program is
running.
37. All Visual Basic .NET projects are saved as files with this file extension.
a. .sln
b. .vb
c. .proj
d. resx
38. You can view the properties window when the project is available by doing any of the following actions
except:
a. pressing the F4 key
b. pressing the Ctrl/Alt/P keys
c. by clicking on the properties icon above the Solutions explorer window
d. go to the view menu and the clicking properties.
40. During design time a control will _________________ when the Visible property is set to false.
a. be Active
b. not be visible
c. be displayed
d. be inactive
41. You can display the Code window in all of the following ways except:
a. Click view code button on the Solution Explorer window.
b. Click Project on the menu bar, and then click show all files.
c. Click View on the menu bar, and then click the Code command.
d. Press the F7 key.
42. A _________________ is a section of code that may be hidden from view, or collapsed.
4
a. code region
b. code segment
c. a sub procedure
d. code window
43. If you want to prevent the user from resizing, minimizing, or maximizing a window, you would change the
form’s _________________ property.
a. WindowState
b. ShowInTaskBar
c. MinMaxSize property
d. FormBorderStyle
44. You lock all of the controls on a form during design time by
a. left-clicking the form, then clicking Locked on the properties window.
b. Right-clicking on an empty spot on the form, and selecting the Lock Controls option
from the pop up menu.
c. Clicking Window on the Menu Bar, then clicking Lock Controls.
d right-clicking the form, then clicking the lock controls icon on the toolbar.
45. A Label control’s _________________ property allows a label to change size to fit the amount of text
in its text property
a. Autosize
b. Size
c. TextAlign
d. Visible
47. You can run an application in all of the following ways except
a. Click the start button on the toolbar.
b. Press the Ctrl F4 keys.
c. Press the F5 key.
d. Click Debug on the menu bar, and then click Start on the Debug menu.
48. Intellisense___________________________
a. provides hints about the input data requested from the user
b. provides some automatic code completion while developing a program
c. allows the user to easily modify properties for a control at design time
d. is a feature that will help the programmer use proper naming conventions
49. When you have an item selected and then you press the F1 key, the _________________ is displayed.
a. properties window
b. the solution explorer window
c. context-sensitive help
d. tool-tip for the item
51. If you accidentally delete a control you can restore it with the
a. Redo button on the standard toolbar. c. Restore property.
b. Undo button on the standard toolbar. d. Find button on the standard toolbar.
5
52. In the properties window, a few of the properties, including the Name property are enclosed in
___________ to make them appear at the top of the alphabetical list.
a. brackets c. quotes
b. parenthesis d. asterisks
53. Which of the following is not a valid value for the FormBorderStyle property?
a. Fixed3D c. FixedSingle
b. Sizable d. FixedDouble
55. Assume you have a Button control named btnDisplayList. Which is the correct name for an event procedure
that will be executed when the user clicks on the control?
a. _Click btnDisplayList
b. btnDisplayList_Click
c. btnDisplayList_ClickEvent
d. btnDisplayList_ClickButton
57. Choose the correct assignment statement for a Label control named lblTitle that would align the
control’s text with the middle and center of the control’s bounding box?
a. lblTitle.TextAlign = MiddleCenter c. lblTitle.TextAlign =
ContentAlignment.Center
Chapter 3
58. The _________________ control is used to gather input the user has typed on the keyboard.
a. Label
b. Button
c. TextBox
d. ListBox
60. You can break up long lines of code, so they can fit in the code window by _______________
a. hitting the enter key where you want to end the line
b. typing a space, followed by an underscore and then hitting the enter key
c. typing a hyphen where you want to break the line and then hitting enter key
d. hitting the ctrl/enter keys
6
62. The order in which controls receive the focus is called the _________________.
a. control order
b. tab order
c. sequence order
d. focus order
63. The _________________ lets you view the TabIndex of each of the controls on the form.
a. TabIndex viewer
b. sequence selection mode
c. tab order selection mode
d. TaxIndex order mode
64. The statement to declare strName as a variable that can hold text is
a. Dim strName As Text
b. Dim strName As Single
c. Dim strName As Word
d. Dim strName As String
65. When you assign a value of one data type to a variable of another data type, Visual Basic .NET attempts
_________________ .
a. String conversion
b. Explicit conversion
c. Implicit conversion
d. Boolean conversion
66. Each of the Visual Basic data types has a _________________ method, which returns a string
representation of the variable calling the method.
a. Convert
b. String
c. ToString
d. ToText
67. What is the result after evaluating the following expression: 24 Mod 9
a. 6
b. -6
c. 2
d. 5
68. Order the following arithmetic operators from highest precedence to lowest precedence.
a. Exponentiation (the ^ operator), Modulus (the Mod operator), Multiplication and
division, Integer division (the \ operator), Addition and subtraction
b. Exponentiation (the ^ operator), Multiplication and division, Integer division
(the \ operator), Modulus (the Mod operator), Addition and subtraction
c. Exponentiation (the ^ operator), Multiplication and division, Modulus (the Mod
operator), Integer division (the \ operator), Addition and subtraction
d. Exponentiation (the ^ operator), Multiplication and division, Integer division
(the \ operator), Addition and subtraction, Modulus (the Mod operator)
69. The following code will copy the text from a TextBox named txtInput into a Label called lblDisplay.
a. txtInput = lblDisplay
b. txtInput.Text = lblDispl.ay.Text
c. lblDisplay = txtInput
d. lblDisplay.Text = txtInput.Text
70. If you want to execute code automatically when a form is displayed, you can place the code in the
form’s _________________ event procedure.
a. GotFocus
b. Focus
c. Load
d. KeyPress
7
71. The value returned by passing “#45.25” to the CSng function is_________________
a. 45.25
b. 45.3
c. 0
d. No value is returned. The program stops with a runtime error.
72. All of the following are advantages of using named constants except
a. They help make the program more self documenting, since they can describe the
meaning of the constant value.
b. It is easier to make widespread changes to a named constant throughout a program
c. They can be used instead of keywords
d. The value of the constant cannot be changed within the program
73. What is the resulting value after the following function call is executed: FormatNumber(73.394, 1)
a. 73
b. 73.3
c. 73.4
d. 73.39
74. You can perform all of the following actions with variables except:
a. Copy and store values entered by the user, so they may be manipulated
b. Convert a variable to a constant
c. Perform arithmetic on values
d. Remember information for later use in the program
77. The declaration of an integer variable named intLength with an initial value of 12 is
a. Dim intLength As Integer initialize to 12
b. Dim intLength = 12 As Integer
c. Dim intLength As Integer = 12
d. Dim intLength As Integer 12
8
b. Real d. String
81. Which of the following is not a valid rule for naming variables?
a. Names may contain underscores. c. Names may contain digits.
b. Names may contain letters. d. Names may contain spaces.
82. The statement to declare a local variable named Index (note: the prefix has intentionally been left
out) that will store whole numbers is:
a. Dim index As Whole c. Dim Integer As Index
b. Dim index As String d. Dim index As Integer
84. Which of the following has the highest order of precedence in arithmetic expressions?
a. Multiplication and division
b. Addition and subtraction
c. Exponentiation
d. Operators are not significant; all calculations are evaluated from left to right.
85. What will be the value of intAnswer after execution of these statements?
Const intNumA As Integer = 6
Const intNumB As Integer = 4
Const intNumC As Integer = 2
intAnswer = intNumA + intNumB * intNumC
a. 6 c. 20
b. 14 d. 48
Chapter 4
Identify the letter of the choice that best completes the statement or answers the question.
9
88. You want to check the variable sngSales, and change a label lblMessage to say “Great Year” if the value
is at least 50,000. Which of the following code segments does this?
89. You want to determine whether a variable, sngPayAmount, is between 1200 and 1400 inclusively. If the
value is in the range change the lblMessage text to say “Pay amount is in the range” Which of the
following code segments will accomplish this?
90. Visual Basic .NET uses _________________ to store characters, such as A, B, and C in memory.
a. ASCII code
b. BCD code
c. Unicode
d. Extended ASCII code
91. You want to check that the user has entered a value into a text box named txtBox, and respond with
the appropriate message if no value has been entered. Which of the following code segments does this?
a. If txtBox.text = “ “ Then
MessageBox.Show(“No data has been entered”)
End If
c. If txtBox.Text = “” Then
MessageBox.Show(“No data has been entered”)
End If
10
92. To get a copy of a string in all uppercase letters, use the _________________ method of the String
object.
a. ConvertToUpper
b. ToUpper
c. ToString
d. ToUpperCase
93. This function accepts a string as its argument and returns true if the string contains only numeric
digits.
a. IsNumber
b. IsNumeric
c. Val
d. CInt
94. To remove the spaces at the end of a string called strAddress and display the result in label
lblAddress, you would use which of the following statements?
a. lblAddress.Text = TrimStart
b. strAddress.TrimEnd = lblAddress.Text
c. lblAddress.Text = strAddress.Trim
d. lblAddress.Text = strAddress.TrimEnd
95. What is the resulting string that is stored in the String variable strSnip at the end of the code
segment?
a. “ton”
b. “gto”
c. “Was”
d. “Washing”
96. What value is returned by the IndexOf method if the search string is not found?
a. the length of the string + 1
b. 0
c. 1
d. -1
100. Because only one radio button in a group can be selected at any given time, they are said to be
a. asynchronous
b. independent
c. mutually exclusive
11
d. mutually independent
101. The Dim statement for a class-level variable must be outside any procedure, and between the statement
and the _________________ statement.
a. Public Class , End Class
b. Private Sub , End Sub
c. Public Class, End Sub
d. Private Sub, End Class
102. What is the value of sngTaxes for the following program segment runs, assuming the user enters 60000
into the textbox?
a. 24000
b. 18000
c. 12000
d. 6000
103. Given that A is a True statement and B is a True statement, what is the value of the following logical
expression: _________________ A Xor B
a. True
b. False
c. 1
d. 0
104. What is displayed in lblMessage.Text after the following code segment is executed?
a. True
b. False
c. Jim is greater
d. John is greater
105. What is the value of the String variable strSecond after the following code is executed?
a. “1 2 3 bUTTON mY sHOE”
b. “1 2 3 BUTTON MY SHOE”
c. “ BUTTON MY SHOE”
d. “123BUTTONMYSHOE”
12
106. Which of the following statements will display a message box with the text “line 1” on one line, and
the text “line 2” on another line?
a. MessageBox.Show(“line 1” & “\n” & “line 2”)
b. MessageBox.Show(“line 1” & ControlCharsCrLf & “line 2”)
c. MessageBox.Show(“line 1” _
“line 2”)
d. MessageBox.Show(“line 1” & ControlChars.Crlf & “line 2”)
107. Choose the correct Select Case statement which will check the value of a variable intMyNum and process
as following:
108. Considering the logic of the If ... Then... Else statement, what will be the result of the following
code if a score of 88 is entered?
If intScore < 80 Then
grade = “C”
Else intScore > 80 Then
grade = “A”
a. C c. A
13
b. “A” d. It will not run
109. What would the following code return - with proper understanding of the If ... Then ... ElseIf
statement when the score of 85 is entered?
If intScore > 60 Then
Grade = “Passed”
ElseIf intScore > 70 Then
Grade = “Your mother still loves you”
ElseIf intScore >80 Then
Grade = “Your parents would be Proud”
ElseIf intScore > 90 Then
Grade = “Your family is proud of you”
End If
a. Your family is proud of you c. Your mother still loves you
b. Your parents would be Proud d. Passed
111. This statement tests the value of an expression once and then uses that value to determine the result.
a. If ... Now Then ... Never c. If ... then ... Else
b. If ... Then ... ElseIf d. Select Case ... Case Else
112. Which of the following methods can you use to convert a string to an Integer?
a. IntC c. CNumber
b. CInteger d. CInt
113. Which is the correct general format for the method call that displays a message box?
a. Messagebox.message (Caption, Buttons, Icon, DefaultButton)
b. Messagebox.show (Message, Caption, Buttons, Icon, DefaultButton)
c. Messagebox.show (MessageBox, CaptionBox, ButtonsBox, IconBox, DefaultButton)
d. a or b are both correct
Chapter 5
114. This provides a simple way to gather input without placing a text box on a form.
a. List Boxes
b. Message Boxes
c. Text Boxes
d. Input Boxes
116. To get the number of items stored in a ListBox, you would use the _________________ property.
a. count
b. Items
c. Items.count
d. number
14
118. Setting this property to True will put the items in the list into alphabetical order.
a. Sorted
b. Organized
c. Selection
d. Alphabetic
119. This method will erase all the items in the list box.
a. Items.Delete
b. Items.Erase
c. Items.Clear
d. Items.Remove
120. A For Next loop begins with the following statement. What is the purpose of the Step clause?
121. What is the difference in the execution of the Do Until Loop (first example) and the Do Loop Until
(second example).
'Second Example
sngPayAmount = 400
Do
' Processing Steps
sngPayAmount = sngPayAmount – 50
Loop Until sngPayAmount > 150
For intIndex = 5 To 1
ListBox.Items.Add (intIndex )
Next
123. What is displayed in lblSum after the following code segment is executed.
a. 9
15
b. 16
c. 25
d. 36
124. What is the code that will get the number of items checked in a checked list box named clbMovieNames?
The total should be stored in intCheckedMovies.
126. A control’s _________________ event is triggered just before the focus shifts to another control whose
CausesValidation property is set to true.
a. Verified
b. Validated
c. Verifying
d. Validating
127. These two properties can be used in code to automatically select the text in a text box.
a. Select, Length
b. Start, Length
c. Select, Section
d. SelectionStart, SelectionLength
128. This property determines the amount of time, in milliseconds, that elapses between the user pointing
the mouse at a control and the tool tip appearing.
a. FinalDelay
b. ReshowDelay
c. InitialDelay
d. AutoPopDelay
129. This function returns the periodic payment amount for a loan.
a. Pmt
b. IPmt
c. PPmt
16
d. LPmt
130. How would you get scroll bars on your list box?
a. Set the scrollFlag of the listbox to True
b. Visual Basic .NET will automatically add a scroll bar to the list box when it
contains more items than can be displayed.
c. You cannot get scroll bars for a list box, only for a ComboBox.
d. If you set the CheckedListBox flag at design time, then you will get scroll bars at
run time.
132. Which of the following code segments correctly does the following? Employs a For loop with an InputBox
to prompt the user four times for the cost of a T-shirt. The program will calculate a 25% discount
for each of the 4 values and then display the discounted shirt prices in list box lstResult.
For intIndex = 0 To 4
sngCost = CSng(InputBox("Enter the cost of shirt " & intIndex))
sngDiscountPrice = sngCost * 0.75
lstResult.Items.Add(sngDiscountPrice)
Next
For intIndex = 0 To 4
sngCost = CSng(InputBox("Enter the cost of shirt " & intIndex))
sngDiscountPrice = sngCost - .25 * sngCost
Next
lstResult.Items.Add(sngDiscountPrice)
For intIndex = 1 To 4
sngCost = CSng(InputBox("Enter the cost of shirt " & intIndex))
sngDiscountPrice = sngCost * 0.75
lstResult.Items.Add(sngDiscountPrice)
Next
For intIndex = 1 To 4
sngCost = CSng(InputBox("Enter the cost of shirt " & intIndex))
sngDiscountPrice = sngCost * 0.25
lstResult.Items.Add(intIndex & " " & sngDiscountPrice)
Next
133. Which of the following code fragments finds the average of 5 numbers input via an input box and
displays the result in lblResult using a Do While statement?
a. intCount = 5
intSum = 0
Do While intCount = 5
intSum = CInt(InputBox(“enter a number”))
sngAvg = intSum/intCount
lblResult.Text = sngAvg.ToString
Loop
17
b. intCount = 5
intSum = 0
Do While intCount <=5
value = CInt(InputBox(“enter a number”))
intSum = intSum + value
sngAvg = intSum/ intCount
Loop
lblResult.Text = sngAvg.ToString
c. intCount = 0
intSum = 0
Do While intCount <= 5
value = CInt(InputBox(“enter a number”))
intSum = intSum + value
Loop
Avg = intSum/intCount
lblResult.Text = sngAvg.ToString
d. intCount = 0
intSum = 0
Do While intCount < 5
Value = CInt(InputBox(“enter a number”))
intSum = intSum + value
intCount += 1
Loop
Avg = intSum/5
lblResult.Text = sngAvg.ToString
134. A counter is a _____________________ that can be incremented or decremented each time a loop runs.
a. method c. integer
b. statement d. variable
136. The ToolTip is a _________________ that allows the user to creates a small box that displays when
the user places the mouse over the control.
a. method c. function
b. property d. control
138. Using a twip as a measurement, what Xpos position would place the input box ½ inch from the left edge?
a. 150 c. 720
b. 550 d. 1400
intCount = 0
Do While intCount < 10
lstOutput.Items.Add (“Good Job”)
Loop
18
Dim intCount As Integer = 0
Do
lstOutPut.Items.Add (“I love Visual Basic 2005”)
intCount += 1
Loop While intCount > 10
141. Which loop is a pretest that first initializes a counter variable and then increments the counter
variable at the end of each iteration?
Chapter 6
142. If you want to prevent statements from outside a form from accessing a procedure, you set the access
specifier to _________________ in the procedure’s declaration.
a. Private
b. Public
c. Static
d. Scope
143. If a procedure is called more than once in a program, the values stored in the procedure’s local
variables will persist only if declared with the _________________ keyword.
a. Const
b. Public
c. Static
d. Dim
144. A _________________ is a special variable in a Sub or Function heading that receives an argument’s
value/address from a calling procedure.
a. temporary variable
b. constant
c. original argument
d. parameter
145. Which of the following calls does not pass in valid arguments to the following GetANumber subprocedure?
a. GetANumber(intX)
b. GetANumber(3 + 5 * 8 + intX)
c. GetANumber(intX + 3, intY)
d. GetANumber(Cint(txtNumber.Text))
146. When calling a Sub Procedure, the arguments and the corresponding parameters must agree in all of the
following ways except one of the following.
a. The order of arguments and parameters must correspond
b. The names of the arguments and parameters must correspond
c. The type the arguments and parameters must correspond
d. the number of the arguments and the parameters must be the same
147. Which of the following code is a correctly written function named Average that will accept three
integers as parameters, calculate their average and return the result.
19
Single
Average = (intX + intY + intZ) / 3
End Function
Public Function sum( ByVal intA As Integer, ByVal intY As Integer) As Integer
Dim intAns As Integer
intAns = intX + intY
End Function
a. 4
b. 5
c. 6
d. 7
150. What is the value of intTotal after the following code is executed?
a. 0
b. 5
c. 10
d. 13
20
151. In break mode, pressing _________________ will activate the Step Into command.
a. F5
b. Ctrl F5
c. F8
d. Shift F8
153. Which of the following does not apply to using Sub procedures and functions?
154. Which of the following is a Sub procedure that will keep track of the number of times it was called?
a. Private Sub KeepTrack( ByVal intCount As Integer)
intCount += 1
lstResult.Items.Add(intCount)
End Sub
156. Which of the following is a correctly written Sub procedure that uses an input box to get an integer,
which is returned to the calling program?
a. Public Sub GetInput( ByVal intNumber As Integer)
intNumber = CInt(InputBox(“Enter an Integer”))
End Sub
21
End Sub
157. Which of the following functions accepts a parameter named dblSales, and returns the commission to the
calling program where commission is dblSales * dblCommission rate, based on the following table?
22
End Function
158. Which VB debugging command will allow the programmer to execute all of the procedures/functions in the
program?
a. Step Into
b. Step Over
c. Step Out
d. Step All
161. When an argument is passed to a procedure this way, the procedure has access to the original argument
and may make changes to it.
a. ByValue
b. ByAddress
c. ByRef
d. ByDefault
162. Which of the following calls does not pass in valid arguments to the following GetANumber Sub
Procedure?
a. GetANumber(intX)
b. GetANumber(3 + 5 * 8 + intX)
c. GetANumber(intX +3, intY)
d. GetANumber(Cint(txtNumber.Text))
163. If you do NOT provide an access specifier for a Sub Procedure then …
a. it will be Private
b. it will be Protected
23
c. it will be Friend
d. it will be Public
164. What would be the value of the variable IntShowNum the next time the Sub Procedure ShowLocalNum is
called to run?
Sub ShowLocalNum ( )
Dim IntShowNum As Integer
MessageBox.Show(IntShowNum.Tostring)
IntShowNum = 10
End sub
a. 0
b. 1
c. 10
d. Can’t be determined
167. Which is the correct general format to declare a variable that remains the same between procedure
calls?
24