Visual Basic Chapter 3 Open Book 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.Multiple variables with different data types can be declared in a single statement.

____4.An identifier can contain spaces.

____5.An Integer variable that is declared but not initialized stores the value 1.

____6.Grouping variables together in a single statement is good programming style only when the variables represent related items.

____7.Theoperator is used to assign a new value to a variable.

____8.The value of a variable is changed through assignment.

____9.A variable can be declared and initialized in the same statement.

____10.The Val() function converts text box data to a numeric value.

____11.Values represented by the Double data type are referred to as floating point.

____12.The Integer data type requires more memory than the Double data type.

____13.If a value is large and could possibly have a decimal portion, Integer is the best data type choice.

____14.A variable of type Double is initialized to 0 by default.

____15.A variable of type String is initialized to 0 by default.

____16.A variable of type Char is initialized toNothingby default.

____17.A Char assignment requires double-quotation marks (").

____18.An error will be generated when hello is assigned to an Integer variable.

____19.A value with a decimal portion is automatically rounded to a whole number when assigned to an Integer variable.

____20.A local declaration allows a variable to be accessible to any code in the Form class.

____21.It is good programming practice to keep the scope of variable declarations as wide as possible.

____22.A global declaration allows a variable to be accessible only in the procedure it is declared in.

____23.A module-level declaration is global to any code in the Form class.

____24.In a numeric expression, integer division is performed after modulus division.

____25.Modulus division truncates the decimal portion of the quotient to result in an integer.

____26.The value of a declared constant can be changed anywhere in the program code.

____27.The value of a constant can be assigned only in the declaration.

____28.A constant value can be changed from its initial assignment.

____29.Identifiers are case sensitive.

____30.Keywords can be used as variable identifiers.

____31.Nothing is a keyword.

____32.In Visual Basic, widget and Widget refer to the same variable.

____33.A program with a semantic error will produce unexpected results.

____34.A run-time error is also called a syntax error.

____35.Logic errors must be found by the programmer.

____36.The statement Dim Function As Integer will generate a syntax error.

____37.A run-time error halts program execution at the statement that cannot be executed.

____38.Debugging is the process of getting an application to work correctly.

____39.A breakpoint is a statement that has been marked as a stopping point.

____40.Commenting out selected lines of text is a debugging technique.

____41.Application deployment is used to distribute a Visual Basic application to other computer systems.

____42.A Visual Basic application can be published to a website.

Multiple Choice

Identify the choice that best completes the statement or answers the question.

____1.Which is a valid identifier?

a. / $12 / c. / 55
b. / Integer / d. / diameter

____2.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

____3.How many values can a variable store at one time?

a. / 1 / c. / 5
b. / 2 / d. / 10

____4.Which operator is used to assign a new value to a variable?

a. / = / c. / *
b. / == / d. / –

____5.Which statement declares the variable radius and assigns it a value of 15?

a. / Dim radius = 15 / c. / Dim radius As Integer = 15
b. / Dim radius As Integer == 15 / d. / Dim radius = 15 As Integer

____6.What is the final value offinalNumberafter the last statement executes?

Dim startingNumber As Integer = 10

Dim finalNumber As Integer = 25

startingNumber = finalNumber / 5

finalNumber = startingNumber + 5

a. / 5 / c. / 20
b. / 10 / d. / 25

____7.In the assignment statement Dim x As Integer = 20, the value 20 is called

a. / a variable / c. / an initializer
b. / a literal / d. / an expression

____8.The TextBox control TextAlign property

a. / sets the alignment of the text box to match it corresponding label.
b. / determines what text is displayed in the text box.
c. / sets the alignment of the text relative to the form.
d. / sets the alignment of the text relative to the text box.

____9.The TextBox control (Name) property

a. / sets the alignment of the text relative to the text box.
b. / identifies a control for the programmer.
c. / determines what text is displayed in the text box.
d. / sets the alignment of the text relative to the form.

____10.The TextBox control Text property

a. / sets the alignment of the text relative to the text box.
b. / identifies a control for the programmer.
c. / determines what text is displayed in the text box.
d. / sets the alignment of the text relative to the form.

____11.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

____12.The statement weight=Val("Forty-eight kilograms") returns a value of

a. / forty-eight. / c. / 0.
b. / 48. / d. / 48 kilograms.

____13.The statement weight=Val("48 kilograms") returns a value of

a. / forty-eight and a half kilograms. / c. / 0.
b. / 48. / d. / 48000.

____14.A procedure that performs a task and returns a value is called

a. / an assignment. / c. / a function.
b. / aTextChanged event. / d. / an event procedure.

____15.Which is executed when the user types in a text box?

a. / a variable assignment. / c. / a function.
b. / aTextChanged event procedure. / d. / an exception.

____16.Which is not a primitive data type?

a. / Integer / c. / String
b. / Double / d. / Boolean

____17.Which data type declares a variable that stores a true or false value?

a. / Integer / c. / Char
b. / Double / d. / Boolean

____18.Which Visual Basic keyword is used to clear labels?

a. / Default / c. / Nothing
b. / Erase / d. / Static

____19.Which data type declares a variable that stores a positive or negative whole number?

a. / Integer / c. / Char
b. / Double / d. / Boolean

____20.How many bytes are used to store an Integer variable?

a. / 2 / c. / 8
b. / 4 / d. / 16

____21.Which data type is most appropriate for whether an employee qualifies for a bonus?

a. / Integer / c. / Boolean
b. / Decimal / d. / Char

____22.Which data type is most appropriate for the number of students in a class?

a. / Integer / c. / Boolean
b. / Double / d. / Char

____23.In the assignment statement Dim x As Integer = 5.6, x is assigned the value

a. / 0. / c. / 5.6.
b. / 5. / d. / 6.

____24.Which operator is used for modulus division?

a. / / / c. / %
b. / \ / d. / Mod

____25.What is the result of the following expression whenxis 3576?

(x\10) Mod 10

a. / 6 / c. / 76
b. / 7 / d. / 357

____26.What is the result of the following expression when x is 125?

x Mod 6

a. / 0 / c. / 20
b. / 5 / d. / 20.5

____27.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.

____28.Which keyword does a constant declaration begin with?

a. / Static / c. / Integer
b. / Const / d. / Final

____29.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

____30.Which type of error occurs in statements that are syntactically correct, but produce undesired or unexpected results?

a. / syntax error / c. / run-time error
b. / semantic error / d. / exception error

____31.Which type of error occurs when a statement violates the rules of Visual Basic?

a. / syntax error / c. / run-time error
b. / semantic error / d. / exception error

____32.A statement that has been marked as a stopping point is called a

a. / watching statement. / c. / debug statement.
b. / breakpoint. / d. / stop point.

____33.A Watch window can be used to

a. / display the application interface.
b. / examine values during the execution of a program.
c. / switch to the Code window.
d. / display online help.