0% found this document useful (0 votes)
2 views10 pages

Visual Basic

The document provides a comprehensive overview of key concepts in Visual Basic (VB), including definitions and characteristics of variables, data types, scopes, and controls. It includes multiple-choice questions and answers related to variable declaration, data types, and control functionalities in VB. The content serves as a study guide for understanding fundamental programming concepts in Visual Basic.

Uploaded by

sappu7578
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views10 pages

Visual Basic

The document provides a comprehensive overview of key concepts in Visual Basic (VB), including definitions and characteristics of variables, data types, scopes, and controls. It includes multiple-choice questions and answers related to variable declaration, data types, and control functionalities in VB. The content serves as a study guide for understanding fundamental programming concepts in Visual Basic.

Uploaded by

sappu7578
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

In Visual Basic (VB), what is a variable?

A) A constant value that cannot be changed during program execution.


B) A storage location in memory with a name and type that can hold data which may change
during execution.
C) A procedure that performs a specific task.
D) A type of data structure that holds a collection of similar values.

Correct Answer: B) A storage location in memory with a name and type that can hold data
which may change during execution.

Which keyword is commonly used to declare a variable in Visual Basic (VB)?

A) Var
B) Dim
C) Let
D) Declare

Correct Answer: B) Dim

In Visual Basic (VB), what does the term "scope" refer to?

A) The data type of a variable


B) The lifetime of a variable
C) The accessibility of a variable within different parts of the program
D) The name of a variable

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?

A) It can be accessed by any part of the program.


B) It is accessible only within the procedure or block of code where it is declared.
C) It retains its value between different calls to the same procedure.
D) It is automatically accessible by all modules in the program.

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.

In Visual Basic (VB), what does namespace-level scope refer to?

A) A variable that is accessible only within a single procedure.


B) A variable that is accessible throughout the entire module where it is declared.
C) A variable or type that is accessible across all modules within the same namespace.
D) A variable that is only accessible within a specific block of code.

Correct Answer: C) A variable or type that is accessible across all modules within the same
namespace.

What is the lifetime of a local variable in Visual Basic (VB)?

A) It persists for the entire duration of the program execution.


B) It lasts for the duration of the module where it is declared.
C) It lasts only for the duration of the procedure or block where it is declared.
D) It remains active for the duration of the application session.

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?

A) It can be accessed from any procedure within the module.


B) Its value is retained between multiple calls to the same procedure.
C) It is only accessible within the specific block where it is declared and cannot be used outside
that block.
D) It is automatically initialized to its default value every time the procedure is called.

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)?

A) It lasts only for the duration of a single procedure call.


B) It is valid for the entire duration of the application session.
C) It persists for as long as an instance of the class exists and is deallocated when the instance is
destroyed.
D) It remains active throughout the entire module where it is declared.

Correct Answer: C) It persists for as long as an instance of the class exists and is deallocated
when the instance is destroyed.

Which of the following is the correct way to declare a variable in VB.NET?

A) Dim age As Integer


B) Dim age Integer
C) variableName As Integer
D) var age Integer

Correct Answer: A) Dim age As Integer

What is the default value of an uninitialized variable in VB.NET?

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.

What is the default value of an uninitialized Integer variable in VB.NET?


A) 0
B) 1
C) -1
D) Nothing

Correct Answer: A) 0

What is the default size of the Byte and Long data types in Visual Basic (VB)?

A) Byte - 1 byte, Long - 4 bytes


B) Byte - 2 bytes, Long - 8 bytes
C) Byte - 1 byte, Long - 8 bytes
D) Byte - 2 bytes, Long - 4 bytes

Correct Answer: C) Byte - 1 byte, Long - 8 bytes

In Visual Basic (VB), what is the default size of the Integer and Double data types?

A) Integer - 2 bytes, Double - 4 bytes

B) Integer - 4 bytes, Double - 8 bytes

C) Integer - 4 bytes, Double - 16 bytes

D) Integer - 2 bytes, Double - 8 bytes

Correct Answer: B) Integer - 4 bytes, Double - 8 bytes

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

Correct Answer: B) Decimal

In Visual Basic (VB), which data type is used to store a single Unicode character?
A) String
B) Char
C) Integer
D) Boolean

Correct Answer: B) Char

Which of the following is not a data type in Visual Basic (VB)?

A) short
B) Char
C) Double
D) Int

Correct Answer: 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

Correct Answer: C) Const myConstant As Integer = 10

Which of the following methods is used to resize an array in Visual Basic (VB)?

A) ReDim
B) Resize
C) Dim
D) ReSizeArray

Correct Answer: A) ReDim

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

Correct Answer: A) ReDim Preserve

Which data type is used to store whole numbers in Visual Basic (VB)?
A) Double
B) Single
C) Integer
D) String

Correct Answer: C) Integer

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

Correct Answer: B) Decimal

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

Correct Answer: B) 4 bytes

What is the default index of the first element of an array in VB.NET?

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

Correct Answer: B) False

Which data type is used to store text data in Visual Basic (VB)?
A) Integer
B) String
C) Char
D) Boolean

Correct Answer: B) String

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

Correct Answer: C) 0 to 255

A) Dim arrayName(5, 5) As Integer


B) Dim arrayName As Integer(5, 5)
C) Dim arrayName(5) As Integer(5)
D) Dim arrayName(5, 5)

Correct Answer: A) Dim arrayName(5, 5) As Integer

What is the main difference between a Function and a Sub in Visual Basic (VB)?

A) A Function returns a value, while a Sub does not.


B) A Sub returns a value, while a Function does not.
C) Both Function and Sub return values.
D) Both Function and Sub are used for input/output operations.

Correct Answer: A) A Function returns a value, while a Sub does not.

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

Correct Answer: B) Next

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

Correct Answer: 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

Correct Answer: C) GoTo

In Visual Basic (VB), what is a "Form"?

A) A method
B) A container for controls
C) A data structure
D) A function

Correct Answer: B) A container for controls

Which control in Visual Basic (VB) is used to describe other controls?

A) Label
B) TextBox
C) Button
D) Panel

Correct Answer: A) Label

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) TextBox

What is the purpose of the InputBox function in Visual Basic (VB)?

A) To display a message to the user


B) To input text from the user through a dialog box
C) To display a list of options to the user
D) To create a new form

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)?

A) To input text from the user


B) To display information or a message to the user
C) To create a new form
D) To display a list of options to the user

Correct Answer: B) To display information or a message to the user

What is the main function of a Button control in Visual Basic (VB)?

A) To display text to the user


B) To receive text input from the user
C) To trigger an event or action when clicked
D) To display images

Correct Answer: C) To trigger an event or action when clicked

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

Correct Answer: C) ListBox

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

Correct Answer: C) ComboBox

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy