Home »
MCQs
VB.NET MCQs (Multiple-Choice Questions)
Practice these VB.NET MCQs (Multiple-Choice Questions) with answers and explanations to test your knowledge of Visual Basic .NET programming, including variables, data types, operators, control statements, arrays, procedures, classes, inheritance, interfaces, exception handling, collections, delegates, events, LINQ, and .NET programming concepts.
VB.NET MCQs
These VB.NET multiple-choice questions cover fundamental and intermediate concepts of Visual Basic .NET programming. They are useful for students, developers, interview preparation, competitive examinations, and technical assessments.
List of VB.NET MCQs
The following VB.NET MCQs include both conceptual and code-based questions covering important language features and programming techniques.
1. What does VB.NET stand for?
- Visual Basic Network
- Visual Basic .NET
- Visual Binary .NET
- Virtual Basic Network Technology
Answer: B) Visual Basic .NET
Explanation:
VB.NET stands for Visual Basic .NET and is Microsoft's object-oriented programming language for the .NET platform.
2. Which company developed Visual Basic .NET?
- Oracle
- Microsoft
- IBM
- Sun Microsystems
Answer: B) Microsoft
Explanation:
Visual Basic is a Microsoft programming language designed for developing applications on the .NET platform.
3. Which keyword is used to declare a variable in VB.NET?
Dim
Var
Declare
Let
Answer: A) Dim
Explanation:
The Dim statement is commonly used to declare variables in VB.NET.
4. Which of the following correctly declares an Integer variable in VB.NET?
Dim age As Integer
Integer age
var age As Integer
Declare age Integer
Answer: A) Dim age As Integer
Explanation:
VB.NET uses the Dim statement followed by the variable name and As keyword to specify its type.
5. Which data type is used to store a Boolean value?
Boolean
Bit
Logical
Flag
Answer: A) Boolean
Explanation:
The Boolean data type represents logical values such as True and False.
6. Which VB.NET data type is commonly used to store a sequence of characters?
String
CharArray
Text
CharacterSet
Answer: A) String
Explanation:
The String type represents a sequence of Unicode characters.
7. Which data type represents a single Unicode character in VB.NET?
Char
Character
SingleChar
TextChar
Answer: A) Char
Explanation:
The Char data type represents a single Unicode character.
8. Which keyword is used to declare a constant in VB.NET?
Const
Constant
Fixed
StaticValue
Answer: A) Const
Explanation:
The Const statement declares a constant whose value cannot be changed after declaration.
9. Which keyword can be used to explicitly specify the type of an expression or variable?
As
Type
With
Define
Answer: A) As
Explanation:
The As keyword is used in declarations such as Dim count As Integer to specify the data type.
10. Which operator is used for assignment in VB.NET?
=
:=
<-
==
Answer: A) =
Explanation:
VB.NET uses the single equals sign = for assignment and also for equality comparison depending on the context.
11. Which operator is used for integer division in VB.NET?
\
/
DIV
%
Answer: A) \
Explanation:
The backslash operator \ performs integer division in VB.NET.
12. Which operator returns the remainder of a division operation?
Mod
Rem
%
Remainder
Answer: A) Mod
Explanation:
The Mod operator returns the integer remainder after division.
13. Which operator is used for string concatenation in VB.NET?
&
+
.
||
Answer: A) &
Explanation:
The & operator concatenates strings in VB.NET.
14. Which operator is used for exponentiation in VB.NET?
^
**
EXP
^^
Answer: A) ^
Explanation:
The caret operator ^ performs exponentiation in VB.NET.
15. Which keyword is used for a conditional statement in VB.NET?
If
When
Check
Condition
Answer: A) If
Explanation:
The If statement executes code based on whether a Boolean condition evaluates to true.
16. Which statement is used for selecting among multiple values of an expression?
Select Case
Choose Case
Switch Value
Case Select
Answer: A) Select Case
Explanation:
Select Case evaluates an expression and executes the matching Case block.
17. Which loop executes a block of code while a condition is true?
While
Repeat
LoopWhileOnly
During
Answer: A) While
Explanation:
A While loop repeats its statements as long as its condition evaluates to true.
18. Which loop is commonly used to iterate through a numeric range in VB.NET?
For...Next
Loop...Range
Repeat...Next
Range...End
Answer: A) For...Next
Explanation:
The For...Next loop is commonly used when a loop variable progresses through a specified numeric range.
19. Which loop is used to iterate over the elements of a collection or array?
For Each...Next
For Collection
Each Loop
Iterate...End
Answer: A) For Each...Next
Explanation:
For Each...Next iterates through the elements of a collection or array.
20. Which statement immediately exits the current loop in VB.NET?
Exit
Break
StopLoop
EndLoop
Answer: A) Exit
Explanation:
VB.NET uses statements such as Exit For, Exit While, and Exit Do to leave loops.
21. Which keyword skips the remaining statements in the current loop iteration and continues with the next iteration?
Continue
Skip
NextOnly
Resume
Answer: A) Continue
Explanation:
Statements such as Continue For, Continue While, and Continue Do move execution to the next loop iteration.
22. Which keyword is used to declare a procedure that does not return a value?
Sub
Procedure
Void
Method
Answer: A) Sub
Explanation:
A Sub procedure performs an operation but does not return a value as a function does.
23. Which keyword is used to declare a procedure that returns a value?
Function
ReturnMethod
ValueSub
Result
Answer: A) Function
Explanation:
A Function procedure returns a value to the calling code.
24. Which keyword specifies that an argument is passed by reference?
ByRef
Ref
Reference
ByReference
Answer: A) ByRef
Explanation:
The ByRef modifier allows a procedure to access and potentially modify the caller's variable rather than working only with a copy of its value.
25. Which keyword specifies that an argument is passed by value?
ByVal
ByValue
Value
Copy
Answer: A) ByVal
Explanation:
The ByVal modifier passes the argument by value, so assignment to the parameter does not directly replace the caller's variable.
26. Which keyword is used to define a class in VB.NET?
Class
Object
TypeClass
DefineClass
Answer: A) Class
Explanation:
The Class statement defines a reference type that can contain fields, properties, methods, events, and other members.
27. Which keyword is used to create an object instance in VB.NET?
New
Create
Instance
Object
Answer: A) New
Explanation:
The New keyword is used to create an instance of a class or another type that supports construction.
28. Which procedure is used as a constructor in a VB.NET class?
Sub New
Constructor
Init
Create New
Answer: A) Sub New
Explanation:
Sub New defines a constructor that runs when an instance of the class is created.
29. Which keyword is used to inherit from a base class in VB.NET?
Inherits
Extends
Derives
Base
Answer: A) Inherits
Explanation:
The Inherits statement specifies the base class from which a class derives.
30. Which keyword is used to implement an interface in VB.NET?
Implements
Interface
ImplementsFrom
Uses
Answer: A) Implements
Explanation:
The Implements statement identifies the interface or interfaces whose members the class or structure implements.
31. Which keyword prevents a class from being inherited?
NotInheritable
Sealed
FinalClass
NoInherit
Answer: A) NotInheritable
Explanation:
The NotInheritable modifier prevents other classes from inheriting from the class.
32. Which modifier allows a derived class to replace a base class member's implementation?
Overrides
Replace
Overload
Rewrite
Answer: A) Overrides
Explanation:
The Overrides modifier provides a new implementation of an overridable base-class member.
33. Which modifier indicates that a class member can be overridden by a derived class?
Overridable
Virtual
Overrideable
Replaceable
Answer: A) Overridable
Explanation:
The Overridable modifier allows a derived class to override a base class member.
34. Which modifier creates a shared member that belongs to the type rather than a particular object instance?
Shared
Static
Global
Common
Answer: A) Shared
Explanation:
The Shared modifier declares a member that is associated with the type itself rather than a particular instance.
35. Which VB.NET construct is similar to a class but cannot be instantiated as an object?
Module
Namespace
Interface
Enum
Answer: A) Module
Explanation:
A VB.NET module is similar to a class in some ways, but it has exactly one implicit instance and its members are implicitly Shared. A module cannot be instantiated with New.
36. Which statement correctly declares an array containing three Integer values?
Dim numbers() As Integer = {10, 20, 30}
Dim numbers As Integer = {10, 20, 30}
Array numbers Integer = 10,20,30
Dim numbers<Integer> = 10,20,30
Answer: A) Dim numbers() As Integer = {10, 20, 30}
Explanation:
The syntax declares an Integer array and initializes it with three elements.
37. Which property returns the number of elements in a VB.NET array?
Length
Count
Size
Elements
Answer: A) Length
Explanation:
The Length property returns the total number of elements in an array.
38. Which statement is used to resize an array while preserving its existing elements?
ReDim Preserve
Resize Preserve
Array.ResizePreserve
ChangeDim Keep
Answer: A) ReDim Preserve
Explanation:
ReDim Preserve changes the size of an array while preserving its existing elements.
39. Which keyword is used to declare an enumeration in VB.NET?
Enum
Enumeration
Enumerate
Values
Answer: A) Enum
Explanation:
The Enum statement defines a set of named constants.
40. Which structure is a value type in VB.NET?
Structure
Class
Module
Delegate
Answer: A) Structure
Explanation:
A Structure is a value type, whereas a class is a reference type.
41. Which block is used for structured exception handling in VB.NET?
Try...Catch...Finally
Attempt...Handle...End
Error...Catch...Stop
Exception...Handle...End
Answer: A) Try...Catch...Finally
Explanation:
VB.NET supports structured exception handling through Try, Catch, and Finally blocks. .NET exceptions derive from System.Exception.
42. Which keyword is used to explicitly throw an exception in VB.NET?
Throw
Raise
Error
Exception
Answer: A) Throw
Explanation:
The Throw statement is used to explicitly raise an exception object in VB.NET.
43. Which block is executed whether or not an exception occurs?
Finally
Always
Cleanup
End
Answer: A) Finally
Explanation:
The Finally block is used for cleanup code that should run when control leaves the Try statement, including when an exception occurs.
44. Which collection stores key-value pairs in .NET?
Dictionary(Of TKey, TValue)
List(Of T)
Stack(Of T)
Queue(Of T)
Answer: A) Dictionary(Of TKey, TValue)
Explanation:
Dictionary(Of TKey, TValue) stores values indexed by unique keys.
45. Which keyword is used to declare a delegate in VB.NET?
Delegate
FunctionPointer
Callback
MethodReference
Answer: A) Delegate
Explanation:
The Delegate statement defines a reference type that can represent a method with a particular signature.
46. Which keyword is used to declare an event in VB.NET?
Event
Raise
Notify
Signal
Answer: A) Event
Explanation:
The Event statement declares an event that can be raised by a class or other type and handled by subscribers.
47. Which keyword is used to subscribe a procedure to an event in a VB.NET declaration?
Handles
Subscribe
Listen
WithEvent
Answer: A) Handles
Explanation:
The Handles clause associates a procedure with one or more events declared by the specified object or class.
48. Which technology allows VB.NET developers to query collections and data sources using query expressions?
- LINQ
- ADO Classic
- COM Query Language
- VB Query Engine
Answer: A) LINQ
Explanation:
LINQ, or Language Integrated Query, provides query capabilities directly within .NET programming languages, including Visual Basic.
49. What is the output of the following VB.NET code?
Dim numbers() As Integer = {10, 20, 30, 40}
Dim total As Integer = 0
For Each n As Integer In numbers
If n > 20 Then
total += n
End If
Next
Console.WriteLine(total)
- 30
- 50
- 70
- 100
Answer: C) 70
Explanation:
The condition keeps values greater than 20, which are 30 and 40. Their sum is 70, so the program prints 70.
50. What does the following VB.NET LINQ query return?
Dim numbers() As Integer = {5, 10, 15, 20, 25}
Dim result = From n In numbers
Where n > 10
Select n
- 5, 10
- 10, 15, 20
- 15, 20, 25
- 5, 15, 25
Answer: C) 15, 20, 25
Explanation:
The LINQ query filters the array with Where n > 10. Therefore, 15, 20, and 25 satisfy the condition and are returned by the Select clause.
Advertisement
Advertisement