Visual Basic
Visual Basic
Correct Answer: B) A storage location in memory with a name and type that can hold data
which may change during execution.
A) Var
B) Dim
C) Let
D) Declare
In Visual Basic (VB), what does the term "scope" refer to?
Correct Answer: C) The accessibility of a variable within different parts of the program
Question: In Visual Basic (VB), what is the characteristic of a variable with local or procedure
scope?
Correct Answer: B) It is accessible only within the procedure or block of code where it is
declared.
In Visual Basic (VB), which of the following best describes a variable with block-level scope?
A) It can be accessed anywhere within the same class.
B) It can only be accessed within the specific block of code (such as an If statement or For
loop) where it is declared.
C) It can be accessed by any procedure in the same module.
D) It is automatically shared between all instances of a class.
Correct Answer: B) It can only be accessed within the specific block of code (such as an If
statement or For loop) where it is declared.
In Visual Basic (VB), what is the characteristic of a variable with module-level scope/ class
level scope?
A) It can only be accessed within the specific block of code where it is declared.
B) It is accessible to all procedures within the same module/class, but not outside the module.
C) It is accessible throughout the entire program, across all modules.
D) It can only be accessed by the procedure that declared it.
Correct Answer: B) It is accessible to all procedures within the same module/class, but not
outside the module.
Correct Answer: C) A variable or type that is accessible across all modules within the same
namespace.
Correct Answer: C) It lasts only for the duration of the procedure or block where it is
declared.
In Visual Basic (VB), what is a key characteristic of a Static variable?
Correct Answer: B) Its value is retained between multiple calls to the same procedure.
What is the lifetime of a variable with class-level scope in Visual Basic (VB)?
Correct Answer: C) It persists for as long as an instance of the class exists and is deallocated
when the instance is destroyed.
A) 0 for numeric types, False for Boolean, and Nothing for object types.
B) Null for all types.
C) -1 for numeric types, True for Boolean, and Empty for object types.
D) "" (empty string) for all types.
Correct Answer: A) 0 for numeric types, False for Boolean, and Nothing for object types.
Correct Answer: A) 0
What is the default size of the Byte and Long data types in Visual Basic (VB)?
In Visual Basic (VB), what is the default size of the Integer and Double data types?
Which data type in Visual Basic (VB) is suitable for storing a floating-point number with higher
precision?
A) Single
B) Decimal
C) Integer
D) Byte
In Visual Basic (VB), which data type is used to store a single Unicode character?
A) String
B) Char
C) Integer
D) Boolean
A) short
B) Char
C) Double
D) Int
Which of the following is a valid way to declare a constant in Visual Basic (VB)?
A) Const myConstant = 10
B) Dim myConstant As Constant = 10
C) Const myConstant As Integer = 10
D) Dim myConstant = 10 As Constant
Which of the following methods is used to resize an array in Visual Basic (VB)?
A) ReDim
B) Resize
C) Dim
D) ReSizeArray
Which of the following methods is used to resize an array in Visual Basic (VB) without losing
the existing data?
A) ReDim Preserve
B) ReDim
C) Dim Preserve
D) ResizeArray
Which data type is used to store whole numbers in Visual Basic (VB)?
A) Double
B) Single
C) Integer
D) String
Which data type is used to store decimal numbers with a high level of precision in Visual Basic
(VB)?
A) Integer
B) Decimal
C) Char
D) Boolean
What is the size (in bytes) of the Integer data type in Visual Basic (VB)?
A) 2 bytes
B) 4 bytes
C) 8 bytes
D) 16 bytes
A) 1
B) 0
C) -1
D) 10
Correct Answer: B) 0
What is the default value of a Boolean variable in Visual Basic (VB) when it is declared but not
initialized?
A) True
B) False
C) 0
D) Nothing
Which data type is used to store text data in Visual Basic (VB)?
A) Integer
B) String
C) Char
D) Boolean
What is the range of values for the Byte data type in Visual Basic (VB)?
A) 0 to 127
B) -128 to 127
C) 0 to 255
D) 0 to 1024
What is the main difference between a Function and a Sub in Visual Basic (VB)?
What is the main difference between ByVal and ByRef in Visual Basic (VB)?
A) ByVal passes a copy of the value, while ByRef passes the reference to the variable.
B) ByRef passes a copy of the value, while ByVal passes the reference to the variable.
C) ByVal and ByRef both pass a copy of the value.
D) ByVal and ByRef both pass the reference to the variable.
Correct Answer: A) ByVal passes a copy of the value, while ByRef passes the reference to the
variable.
In a For...Next loop in Visual Basic (VB), which keyword is used to move to the next iteration
of the loop?
A) Continue
B) Next
C) Skip
D) Continue For
a For...Next loop in Visual Basic (VB), which keyword is used to skip to the next iteration of
the loop?
A) Continue
B) Next
C) Skip
D) Continue For
Which keyword in Visual Basic (VB) is used to jump to a specified location in the code?
A) Continue
B) Jump
C) GoTo
D) Move
A) A method
B) A container for controls
C) A data structure
D) A function
A) Label
B) TextBox
C) Button
D) Panel
Which control in Visual Basic (VB) is commonly used to input text from the user?
A) Label
B) TextBox
C) Button
D) ListBox
Correct Answer: B) To input text from the user through a dialog box
What is the primary purpose of the MessageBox function in Visual Basic (VB)?
Which control in Visual Basic (VB) allows the user to select one or more items from a list?
A) TextBox
B) ComboBox
C) ListBox
D) Label
Which control in Visual Basic (VB) is used to select an option from a list of items?
A) TextBox
B) Label
C) ComboBox
D) Button