Deck 3: Variables and Calculations
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/41
Play
Full screen (f)
Deck 3: Variables and Calculations
1
The control is used to gather input the user has typed at the keyboard.
A) Label
B) Button
C) TextBox
D) ListBox
A) Label
B) Button
C) TextBox
D) ListBox
C
2
What is the result after evaluating the following expression: 24 MOD 9
A) 6
B) 3
C) 2
D) 5
A) 6
B) 3
C) 2
D) 5
A
3
What will be assigned to the label when the following statements execute? Dim dblVal As Double = 11.75
LblResult.Text = dblVal.ToString("n3")
A) $11.75
B) 11.75
C) 11.750
D) 12
LblResult.Text = dblVal.ToString("n3")
A) $11.75
B) 11.75
C) 11.750
D) 12
C
4
The order in which controls receive the focus is called the __________.
A) control order
B) tab order
C) sequence order
D) focus order
A) control order
B) tab order
C) sequence order
D) focus order
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
5
Which of the following statements will assign the contents of a TextBox control named txtInput into the Text property of a Label control named lblDisplay?
A) txtInput = lblDisplay
B) txtInput.Text = lblDisplay.Text
C) lblDisplay = txtInput
D) lblDisplay.Text = txtInput.Text
A) txtInput = lblDisplay
B) txtInput.Text = lblDisplay.Text
C) lblDisplay = txtInput
D) lblDisplay.Text = txtInput.Text
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
6
A keyboard access key is assigned to a button using the button control's ______property.
A) ShortCut
B) Text
C) AccessKey
D) Alt
A) ShortCut
B) Text
C) AccessKey
D) Alt
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
7
A Date literal can contain _____________.
A) a date
B) a time
C) a floating-point value
D) both a date and a time
A) a date
B) a time
C) a floating-point value
D) both a date and a time
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
8
The operator performs string concatenation.
A) ampersand (&)
B) dollar sign ($)
C) percent symbol (%)
D) pound symbol (#)
A) ampersand (&)
B) dollar sign ($)
C) percent symbol (%)
D) pound symbol (#)
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
9
You can break up a long statement into multiple lines as long as you don't break up a __________.
A) keyword
B) quoted string
C) variable name
D) all of the above
A) keyword
B) quoted string
C) variable name
D) all of the above
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
10
It's possible to view the order in which all controls on a form will receive the focus by __________.
A) clicking TabOrder in the Properties window
B) pressing the Esc key
C) clicking View on the menu bar and then Tab Order
D) all of the above
A) clicking TabOrder in the Properties window
B) pressing the Esc key
C) clicking View on the menu bar and then Tab Order
D) all of the above
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
11
If you want to display multiple lines of information in a message box, use the constant .
A) ControlChars.CrLf
B) strNEW_LINE
C) CARRAGE_RETURN_LINE_FEED
D) vbReturn
A) ControlChars.CrLf
B) strNEW_LINE
C) CARRAGE_RETURN_LINE_FEED
D) vbReturn
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
12
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) Assign a variable's value to a constant
C) Perform arithmetic on values
D) Remember information for later use in the program
A) Copy and store values entered by the user, so they may be manipulated
B) Assign a variable's value to a constant
C) Perform arithmetic on values
D) Remember information for later use in the program
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
13
Only controls capable of receiving some sort of input, such as _________________, may have the focus.
A) labels
B) text boxes
C) buttons
D) text boxes and buttons
A) labels
B) text boxes
C) buttons
D) text boxes and buttons
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
14
All of the following are advantages of using named constants except
A) they can be used in the place of keywords.
B) it is easier to make a consistent change throughout a program.
C) they help make the program more self documenting.
D) they're useful for common values such as pi.
A) they can be used in the place of keywords.
B) it is easier to make a consistent change throughout a program.
C) they help make the program more self documenting.
D) they're useful for common values such as pi.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
15
All numeric and date data types have a ______method that returns a string representation of the contents of the variable.
A) Convert
B) String
C) ToString
D) ToText
A) Convert
B) String
C) ToString
D) ToText
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
16
The contents of a text box may be cleared in Visual Basic code by __________.
A) by assigning the predefined constant String.Empty to the text property
B) by setting the focus on the control and using the delete key
C) by setting the focus on the control and using the back space key
D) by clicking the clear button
A) by assigning the predefined constant String.Empty to the text property
B) by setting the focus on the control and using the delete key
C) by setting the focus on the control and using the back space key
D) by clicking the clear button
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
17
When you assign a value of one data type to a variable of another data type, Visual Basic attempts to perform _____type conversion.
A) string
B) explicit
C) implicit
D) numeric
A) string
B) explicit
C) implicit
D) numeric
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
18
In order to execute code before a form is displayed, place the code in the form's ______event handler.
A) SetUp
B) Load
C) Focus
D) Initialize
A) SetUp
B) Load
C) Focus
D) Initialize
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
19
The statement to declare strName as a variable that can hold character data is _______________.
A) Dim strName As Text
B) Dim strName As Single
C) Dim strName As Word
D) Dim strName As String
A) Dim strName As Text
B) Dim strName As Single
C) Dim strName As Word
D) Dim strName As String
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
20
The value returned by passing #12/31/10# to the CSng function is_________________
A) 12/31/2010
B) 123,110
C) 0
D) No value is returned. A runtime error is generated.
A) 12/31/2010
B) 123,110
C) 0
D) No value is returned. A runtime error is generated.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
21
Identify the error in the following code: Private Sub btnCalculate_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnCalculate.Click
' Declare some variables
Dim sngNumber1 As Single
Dim sngNumber2 As Single
Dim sngSum As Single
' Get the two numbers
SngNumber1 = txtNumber1.Text
SngNumber2 = txtNumber2.Text
' Calculate their sngSum... is the next line working?
SngSum = sngNumber1 + sngNumber2
' Display the result
LblSum.Text = sngSum.ToString
End Sub
A) A local variable is misplaced.
B) A conversion function such as CSng was not used.
C) The variable name sngNumberl was misspelled.
D) The variable sngSum was declared as the wrong data type.
ByVal e As System.EventArgs) Handles btnCalculate.Click
' Declare some variables
Dim sngNumber1 As Single
Dim sngNumber2 As Single
Dim sngSum As Single
' Get the two numbers
SngNumber1 = txtNumber1.Text
SngNumber2 = txtNumber2.Text
' Calculate their sngSum... is the next line working?
SngSum = sngNumber1 + sngNumber2
' Display the result
LblSum.Text = sngSum.ToString
End Sub
A) A local variable is misplaced.
B) A conversion function such as CSng was not used.
C) The variable name sngNumberl was misspelled.
D) The variable sngSum was declared as the wrong data type.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
22
Which statement is true regarding the CInt function?
A) It converts letters to numbers.
B) It cannot convert a string such as "24.7" to an integer.
C) A floating-point number such as 24.7 is converted to 24, dropping its decimal positions.
D) A floating-point number such as 24.7 is converted to 25, rounding its decimal positions.
A) It converts letters to numbers.
B) It cannot convert a string such as "24.7" to an integer.
C) A floating-point number such as 24.7 is converted to 24, dropping its decimal positions.
D) A floating-point number such as 24.7 is converted to 25, rounding its decimal positions.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
23
Which of the following is not a valid Visual Basic data type?
A) Integer
B) Number
C) Decimal
D) Short
A) Integer
B) Number
C) Decimal
D) Short
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
24
What is the purpose of using the following type of structure? Try
Some statements
Catch
Other Statements
End Try
A) To try different types of commands to see which will give you the correct answer.
B) In order to catch run-time errors such as divide-by-zero and not have the program shut down.
C) This is not a valid structure.
D) To use for temporary debugging and remove later when the program functions properly.
Some statements
Catch
Other Statements
End Try
A) To try different types of commands to see which will give you the correct answer.
B) In order to catch run-time errors such as divide-by-zero and not have the program shut down.
C) This is not a valid structure.
D) To use for temporary debugging and remove later when the program functions properly.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
25
When you declare a constant, you must assign it an initial value.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
26
What will be the value of intAnswer after execution of these statements? Const intNumA As Integer = 6
Const intNumB As Integer = 2
IntAnswer = intNumA / intNumB + intNumA * intNumB
A) 12
B) 15
C) 16
D) 18
Const intNumB As Integer = 2
IntAnswer = intNumA / intNumB + intNumA * intNumB
A) 12
B) 15
C) 16
D) 18
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
27
Which of the following has the highest order of precedence in arithmetic expressions?
A) Multiplication and division
B) Addition and subtraction
C) Exponentiation (the ^ operator)
D) None of the above; calculations are always evaluated from left to right.
A) Multiplication and division
B) Addition and subtraction
C) Exponentiation (the ^ operator)
D) None of the above; calculations are always evaluated from left to right.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
28
Which will be displayed in the label lblResult following execution of the code below? Dim dblGrossPay as Double
DblGrossPay = 3500
LblResult.Text = dblGrossPay.ToString("c")
A) 3500.00
B) 3500
C) $3500.00
D) $3,500.00
DblGrossPay = 3500
LblResult.Text = dblGrossPay.ToString("c")
A) 3500.00
B) 3500
C) $3500.00
D) $3,500.00
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
29
What is the value of intE after the following statements execute? Dim intC As Integer
Dim intD As Integer
Dim intE As Integer
IntC = 20
IntD = 3
IntE = intC \ intD
A) 7
B) 6
C) 6.666667
D) 0
Dim intD As Integer
Dim intE As Integer
IntC = 20
IntD = 3
IntE = intC \ intD
A) 7
B) 6
C) 6.666667
D) 0
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
30
When included in the Text property of a button, the && symbols placed side by side will display as a single & character.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
31
Declaration statements ___________________.
A) are only used for variables and are not needed for constants
B) are only allowed in the Declarations section of a form
C) give a name to variables or constants and specify the type of data they will hold
D) both answers B and C are correct
A) are only used for variables and are not needed for constants
B) are only allowed in the Declarations section of a form
C) give a name to variables or constants and specify the type of data they will hold
D) both answers B and C are correct
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
32
A variable is a storage location on a computer's hard drive that holds information while the computer is off.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
33
Which of the following declares a variable that can store the first name of a student?
A) Dim strFirstName as Char
B) Dim strFirstName as Short
C) Dim strFirstName as Long
D) Dim strFirstName as String
A) Dim strFirstName as Char
B) Dim strFirstName as Short
C) Dim strFirstName as Long
D) Dim strFirstName as String
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
34
Which of the following declares an Integer variable named intLength and assigns it the integer literal 12?
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
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
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
35
A Boolean type variable can hold only one of two possible values: _____________.
Or False
B) 0 or 1
C) A or B
D) −1 or +1
Or False
B) 0 or 1
C) A or B
D) −1 or +1
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
36
Variables declared within a button's Click event handler are ________variables.
A) local
B) String
C) global
D) private
A) local
B) String
C) global
D) private
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
37
Which of the following is not true in regard to naming variables?
A) Names may contain underscores.
B) Names may contain letters.
C) Names may contain digits.
D) Names may contain spaces.
A) Names may contain underscores.
B) Names may contain letters.
C) Names may contain digits.
D) Names may contain spaces.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
38
What is the value of dblOutcome after the following section of code executes? Dim dblA as Double
Dim dblB as Double
Dim dblC as Double
Dim dblOutcome as Double
DblA = 45
DblB = 30
DblC = 3 * dblA / dblB
DblOutcome = 2 * (dblC + 15)
A) 39
B) 24
C) 0
D) 80
Dim dblB as Double
Dim dblC as Double
Dim dblOutcome as Double
DblA = 45
DblB = 30
DblC = 3 * dblA / dblB
DblOutcome = 2 * (dblC + 15)
A) 39
B) 24
C) 0
D) 80
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
39
Which of the following declares a variable named intIndex that will be used to store whole numbers?
A) Dim intIndex As WholeNumber
B) Dim intIndex As String
C) Dim Integer As intIndex
D) Dim intIndex As Integer
A) Dim intIndex As WholeNumber
B) Dim intIndex As String
C) Dim Integer As intIndex
D) Dim intIndex As Integer
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
40
A form's Load event takes place when the user first clicks on the form at run time.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
41
A class-level variable ___________________.
A) is declared inside a class but outside any procedure
B) is accessible to all procedures in a class
C) is visible to all statements inside the class
D) all of the above
A) is declared inside a class but outside any procedure
B) is accessible to all procedures in a class
C) is visible to all statements inside the class
D) all of the above
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck