Visual Basic Chapter 3 Test
True/False
Indicate whether the statement is true or false.
____
1. A variable is a name for a value stored in memory.
____
2. A variable must be declared before it is used.
____
3. Grouping variables together in a single statement is good programming style only when the variables
represent related items.
____
4. A variable can be declared and initialized in the same statement.
____
5. The Val() function converts text box data to a numeric value.
____
6. If a value is large and could possibly have a decimal portion, Integer is the best data type choice.
____
7. An error will be generated when hello is assigned to an Integer variable.
____
8. A value with a decimal portion is automatically rounded to a whole number when assigned to an Integer
variable.
____
9. Keywords can be used as variable identifiers.
Multiple Choice
Identify the choice that best completes the statement or answers the question.
____ 10. Which is a valid identifier?
a. $12
b. Integer
c. 55
d. diameter
____ 11. Which is a valid declaration statement?
a. Dim height and width As Integer
b. Dim height, width As Integer
c. Dim height As Integer, width As Integer
d. Dim height, Dim width As Integer
____ 12. How many values can a variable store at one time?
a. 1
c. 5
b. 2
d. 10
____ 13. Which statement declares the variable radius and assigns it a value of 15?
a. Dim radius = 15
c. Dim radius As Integer = 15
Dim
radius
As
Integer
==
15
b.
d. Dim radius = 15 As Integer
____ 14. What is the final value of finalNumber after the last statement executes?
Dim startingNumber As Integer = 10
Dim finalNumber As Integer = 25
startingNumber = finalNumber / 5
finalNumber = startingNumber + 5
a. 5
b. 10
c. 20
d. 25
____ 15. Which should be used to let a user know what input is expected in an application?
a. a variable
c. a prompt
b. an identifier
d. a keyword
____ 16. The statement weight=Val("Forty-eight kilograms") returns a value of
a. forty-eight.
c. 0.
b. 48.
d. 48 kilograms.
____ 17. The statement weight=Val("48 kilograms") returns a value of
a. forty-eight and a half kilograms.
c. 0.
b. 48.
d. 48000.
____ 18. Which data type declares a variable that stores a positive or negative whole number?
a. Integer
c. Char
Double
b.
d. Boolean
____ 19. Which data type is most appropriate for the number of students in a class?
a. Integer
c. Boolean
b. Double
d. Char
____ 20. In the assignment statement Dim x As Integer = 5.6, x is assigned the value
a. 0.
c. 5.6.
b. 5.
d. 6.
____ 21. Which operator is used for modulus division?
a. /
c. %
\
b.
d. Mod
____ 22. What is the result of the following expression when x is 125?
x Mod 6
a. 0
b. 5
c. 20
d. 20.5
____ 23. A named memory location which stores a value that cannot be changed from its initial assignment is called a
a. constant.
c. procedure.
b. variable.
d. function.
____ 24. Which keyword does a constant declaration begin with?
a. Static
c. Integer
b. Const
d. Final
____ 25. Which statement declares a constant named PRICE with a value of 5.25?
a. Const PRICE = 5.25
c. Const As Double PRICE = 5.25
b. Const PRICE As Double = 5.25
d. Final PRICE As Double = 5.25