Dive into the core concepts of VB.NET’s Object-Oriented Programming (OOP). Test your understanding of classes, objects, properties, methods, events, encapsulation, inheritance, and polymorphism with these targeted questions.
Object-Oriented Programming in VB.NET MCQs
Classes and Objects
Which keyword is used to create a new instance of a class in VB.NET?
a) New
b) Class
c) Object
d) Create
What is the main purpose of a class in VB.NET?
a) To define the structure of objects
b) To execute methods directly
c) To handle exceptions
d) To display output
In VB.NET, what is the correct syntax to define a class?
a) Create Class ClassName
b) Define ClassName
c) Class ClassName
d) New ClassName
Which of the following is true about objects?
a) Objects can only store methods.
b) Objects are instances of classes.
c) Objects are defined without classes.
d) Objects cannot have properties.
How do you access a method of an object in VB.NET?
a) Object.Method()
b) Object->Method()
c) Method.Object()
d) Call Method.Object
Properties, Methods, and Events
What is a property in VB.NET?
a) A method with no parameters
b) A variable that stores data
c) A member used to get or set values
d) An event trigger
How can you define a property in VB.NET?
a) Using the Dim keyword
b) Using the Property keyword
c) Using the Function keyword
d) Using the Sub keyword
What does the “Set” block of a property do?
a) Reads the property value
b) Updates the property value
c) Deletes the property
d) Initializes the property
Which statement is true about methods in VB.NET?
a) They are used to declare variables.
b) They are functions or subroutines within a class.
c) They are events triggered during runtime.
d) They cannot accept parameters.
How can you handle an event in VB.NET?
a) Using the Event keyword
b) Using the Handles keyword
c) Using the Triggers keyword
d) Using the Raise keyword
Encapsulation, Inheritance, and Polymorphism
What does encapsulation mean in VB.NET?
a) Grouping data and methods into a class
b) Dividing a program into modules
c) Using multiple methods with the same name
d) Overriding methods in subclasses
How is inheritance implemented in VB.NET?
a) Using the Implements keyword
b) Using the Inherits keyword
c) Using the Override keyword
d) Using the Extends keyword
Which is a benefit of inheritance in VB.NET?
a) Improved data encapsulation
b) Code reusability and hierarchy
c) Reduced class size
d) Prevents method overriding
What is polymorphism in VB.NET?
a) A way to create multiple classes
b) Allowing methods to take many forms
c) Storing multiple values in a single variable
d) Encapsulation of objects
Which type of polymorphism involves method overriding?
a) Static polymorphism
b) Dynamic polymorphism
c) Hybrid polymorphism
d) Functional polymorphism
What keyword is used to override a base class method in VB.NET?
a) Override
b) Overloads
c) Extends
d) New
In VB.NET, which access modifier restricts access to a class and its derived classes?
a) Private
b) Protected
c) Public
d) Friend
Which concept ensures that internal details of a class are hidden?
a) Inheritance
b) Encapsulation
c) Polymorphism
d) Overloading
What is the term for a method that has the same name but different parameters?
a) Method overriding
b) Method hiding
c) Method overloading
d) Method extension
What is the default access level for members of a class in VB.NET?