0% found this document useful (0 votes)
9 views22 pages

Visual Basic Q&A: OOP Concepts & Arrays

Uploaded by

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

Visual Basic Q&A: OOP Concepts & Arrays

Uploaded by

nbabdullahee
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Visual Basic Questions and answers

1. What is Visual Basic?

A. A markup language

B. A database management system

C. An object-oriented programming language

D. A file compression technique

Answer: C

2. Which object-oriented concept represents a blueprint for creating objects?

A. Polymorphism

B. Inheritance

C. Encapsulation

D. Abstraction

Answer: B

3. What is the term for creating a new instance of a class?

A. Instantiation

B. Inheritance

C. Encapsulation

D. Abstraction

Answer: A
4. What does the keyword "New" do in Visual Basic?

A. Declares a new class

B. Calls a constructor to create a new object

C. Releases memory occupied by an object

D. Declares a new variable

Answer: B

5. In object-oriented programming, what is the term for grouping related variables and functions within
a single entity?

A. Inheritance

B. Polymorphism

C. Encapsulation

D. Abstraction

Answer: C

6. Which keyword is used to define a new class in Visual Basic?

A. New

B. Class

C. Object

D. Declare

Answer: B
7. What is the term for inheriting attributes and behaviors from a parent class to a child class?

A. Abstraction

B. Polymorphism

C. Inheritance

D. Encapsulation

Answer: C

8. What is the purpose of the "Me" keyword in Visual Basic?

A. Accesses the current instance of a class

B. Declares a new method

C. Calls a parent class constructor

D. Creates a new variable

Answer: A

9. What is the term for hiding implementation details and exposing only necessary information to the
outside world?

A. Abstraction

B. Polymorphism

C. Encapsulation

D. Inheritance

Answer: C

10. What object-oriented concept allows one class to have multiple forms or behaviors?
A. Encapsulation

B. Polymorphism

C. Inheritance

D. Abstraction

Answer: B

11. Which keyword is used to call a method from the base class in an inheritance hierarchy?

A. Override

B. Super

C. New

D. Me

Answer: B

12. What is the purpose of the "Overloads" keyword in Visual Basic?

A. Declares a new class

B. Calls an overloaded method

C. Overrides a method in a derived class

D. Creates a new variable

Answer: B

13. What is the term for substituting different types of objects into a single method or function?

A. Abstraction
B. Polymorphism

C. Encapsulation

D. Inheritance

Answer: B

14. Which keyword is used to prevent a derived class from overriding a specific method or property?

A. MustInherit

B. Sealed

C. Overridable

D. Public

Answer: B

15. What is the purpose of the "End Class" keyword in Visual Basic?

A. Marks the end of a class definition

B. Terminates the program execution

C. Declares a new variable

D. Calls a method from the base class

Answer: A

16. What is the term for defining a new class based on an existing class?

A. Inheritance

B. Abstraction
C. Encapsulation

D. Polymorphism

Answer: A

17. What is the purpose of constructors in Visual Basic?

A. To create a new instance of a class

B. To define member variables

C. To call methods from the base class

D. To create a new variable

Answer: A

18. Which keyword is used to override a method or property from the base class?

A. Override

B. MustInherit

C. MyBase

D. Me

Answer: A

19. What is the term for using a single interface to refer to multiple related classes?

A. Inheritance

B. Encapsulation

C. Polymorphism
D. Abstraction

Answer: C

20. What is the purpose of the "Shared" keyword in Visual Basic?

A. Declares a new class

B. Calls a shared method or property

C. Inherit attributes and behaviors from another class

D. Calls an overloaded method

Answer: B

21. Which object-oriented concept allows a class to inherit from multiple base classes?

A. Inheritance

B. Polymorphism

C. Encapsulation

D. Abstraction

Answer: A

22. What is the term for declaring a member variable or method without any implementation details?

A. Abstraction

B. Polymorphism

C. Encapsulation

D. Inheritance
Answer: A

23. Which keyword is used to access member variables and methods from the base class within a
derived class?

A. Override

B. MyBase

C. MustInherit

D. Super

Answer: B

24. What is the term for extending the functionality of a class without modifying its original code?

A. Abstraction

B. Polymorphism

C. Inheritance

D. Encapsulation

Answer: C

25. What is the purpose of the "Interface" keyword in Visual Basic?

A. Declares a new variable

B. Calls an overloaded method

C. Defines a contract for implementing certain methods and properties

D. Accesses the current instance of a class


Answer: C

26. Which keyword is used to make a class uninheritable in Visual Basic?

A. MustInherit

B. Overridable

C. Final

D. MyBase

Answer: C

27. What is the term for defining an abstract base class that cannot be instantiated but can provide a
common interface for derived classes?

A. Polymorphism

B. MustInherit

C. Sealed Class

D. Overridable

Answer: B

28. Which keyword is used to access member variables and methods within the current class?

A. Override

B. MyBase

C. Me

D. New

Answer: C
29. What is the purpose of the "Inherits" keyword in Visual Basic?

A. Declares a new class

B. Calls a constructor of a derived class

C. Inherit attributes and behaviors from a base class

D. Creates a new variable

Answer: C

30. Which keyword is used to allow a method or property to be overridden in a derived class?

A. Override

B. Friend

C. NotInheritable

D. Inherits

Answer: A

Arrays

Question 1:

What is an array in Visual Basic?

A) A function that returns multiple values

B) A sequence of variables of the same type

C) A graphical user interface element

D) A data structure used for file input/output


Answer: B) A sequence of variables of the same type

Question 2:

Which keyword is used to declare an array in Visual Basic?

A) Dim

B) Array

C) Var

D) Public

Answer: A) Dim

Question 3:

Which of the following statements initializes an array with a size of 10 elements?

A) Dim myArray(10)

B) Dim myArray() As Integer = New Integer(10) {}

C) Dim myArray() As Integer = {10}

D) Dim myArray(9)

Answer: D) Dim myArray(9)

Question 4:

How do you access an element in an array in Visual Basic?

A) By using the element's index

B) By using the element's value

C) By using the element's index and value


D) By using the element's size

Answer: A) By using the element's index

Question 5:

Which method is used to get the length of an array in Visual Basic?

A) Length()

B) GetLength()

C) Size()

D) Count()

Answer: B) GetLength()

Question 6:

Which statement resizes an array in Visual Basic?

A) ReDim

B) Resize

C) Expand

D) AddElement

Answer: A) ReDim

Question 7:

What is the default lower bound of an array in Visual Basic?

A) 0
B) 1

C) -1

D) It depends on the type of the array

Answer: A) 0

Question 8:

How do you initialize an entire array with the same value in Visual Basic?

A) Using a loop

B) Using the Fill method

C) Using the Initialize method

D) Using the Clone method

Answer: B) Using the Fill method

Question 9:

Which method is used to sort an array in Visual Basic?

A) Sort()

B) OrderBy()

C) SortArray()

D) Arrange()

Answer: A) Sort()

Question 10:
Which keyword is used to pass an array to a method by reference in Visual Basic?

A) ByVal

B) ByRef

C) ArrayRef

D) Array()

Answer: B) ByRef

Question 11:

What is the maximum number of dimensions an array can have in Visual Basic?

A) 1

B) 2

C) 3

D) There is no maximum limit

Answer: D) There is no maximum limit

Question 12:

Which statement is used to create a jagged array in Visual Basic?

A) Dim myArray()() As Integer

B) Dim myArray() As Integer

C) Dim myArray(,) As Integer

D) Dim myArray[][] As Integer

Answer: A) Dim myArray()() As Integer


Question 13:

How do you copy an array in Visual Basic?

A) Using the Copy method

B) Using the Clone method

C) Using the CopyTo method

D) Using the CopyArray method

Answer: C) Using the CopyTo method

Question 14:

Which statement is used to clear the contents of an array in Visual Basic?

A) Clear()

B) Empty()

C) Erase()

D) Remove()

Answer: C) Erase()

Question 15:

Which of the following is NOT a valid data type for an array in Visual Basic?

A) String

B) Double

C) Boolean

D) Object
Answer: D) Object

Class concept using Visual Basic

1. What is a class in Visual Basic?

a) A set of instructions to perform a specific task

b) A blueprint for creating objects

c) A collection of functions and variables

d) A data structure to store information

Answer: b) A blueprint for creating objects

2. In Visual Basic, which keyword is used to define a class?

a) Class

b) Object

c) Sub

d) Function

Answer: a) Class

3. Which of the following is NOT a characteristic of a class in Visual Basic?

a) Polymorphism

b) Inheritance

c) Encapsulation

d) Composition
Answer: d) Composition

4. What is inheritance in Visual Basic?

a) The process of creating multiple instances of a class

b) The ability of a class to inherit properties and methods from another class

c) The process of hiding data within a class

d) The process of overriding a method in a derived class

Answer: b) The ability of a class to inherit properties and methods from another class

5. Which keyword is used to declare a class member as accessible only within the class itself?

a) Private

b) Protected

c) Public

d) Friend

Answer: a) Private

6. Which of the following is an example of encapsulation in Visual Basic?

a) Inheriting properties from another class

b) Restricting access to class members

c) Implementing overloaded methods

d) Creating multiple instances of a class


Answer: b) Restricting access to class members

7. What is the purpose of constructor in Visual Basic?

a) To create a new instance of a class

b) To define the behaviors of a class

c) To encapsulate data within a class

d) To perform arithmetic operations

Answer: a) To create a new instance of a class

8. What is polymorphism in Visual Basic?

a) The ability of a class to have multiple constructors

b) The process of changing the behavior of a method in a derived class

c) The ability of a class to take multiple forms

d) The process of deriving a new class from an existing class

Answer: b) The process of changing the behavior of a method in a derived class

9. Which keyword is used to allow a derived class to access protected members of the base class?

a) Protected

b) Public

c) Private

d) Friend

Answer: a) Protected
10. What is a property in Visual Basic?

a) A special type of method that returns a value

b) A variable that stores information within a class

c) An instance of a class

d) A keyword used to define the visibility of class members

Answer: b) A variable that stores information within a class

11. What is the main advantage of using classes in Visual Basic?

a) Increased code reuse and simplicity of code organization

b) Improved performance and faster execution times

c) Reduced memory consumption and improved resource management

d) Enhanced security and data protection

Answer: a) Increased code reuse and simplicity of code organization

12. Which keyword is used to call the base class constructor from within a derived class in Visual Basic?

a) MyBase

b) MyBaseClass

c) Base

d) BaseClass

Answer: a) MyBase
13. What is method overloading in Visual Basic?

a) The process of hiding the implementation details of a class

b) The process of providing multiple implementations of a method with the same name but different
parameters

c) The process of defining a new class by inheriting from an existing class

d) The process of accessing properties and methods of a class

Answer: b) The process of providing multiple implementations of a method with the same name but
different parameters

14. What is an interface in Visual Basic?

a) A predefined class included in Visual Basic's standard library

b) A language construct that defines a contract for implementing a set of methods and properties

c) A statement that is executed repeatedly in a loop

d) A special type of class used for mathematical calculations

Answer: b) A language construct that defines a contract for implementing a set of methods and
properties

15. What is the purpose of the "Shared" keyword in Visual Basic?

a) To define a class member as shared among all instances of the class

b) To prevent a class member from being accessed outside the class

c) To define a class member as accessible only from within the class

d) To enable a class member to be overridden in a derived class

Answer: a) To define a class member as shared among all instances of the class
16. Which keyword is used to declare a read-only property in Visual Basic?

a) Get

b) Set

c) ReadOnly

d) WriteOnly

Answer: c) ReadOnly

17. What is method overriding in Visual Basic?

a) The process of providing multiple implementations of a method with the same name but different
parameters

b) The process of hiding the implementation details of a class

c) The process of accessing properties and methods of a class

d) The process of changing the behavior of a method in a derived class

Answer: d) The process of changing the behavior of a method in a derived class

18. What is the purpose of the "New" keyword in Visual Basic?

a) To declare a new instance of a class

b) To access a protected member within a derived class

c) To define a method that performs object initialization

d) To specify the number of objects created from a class

Answer: c) To define a method that performs object initialization

19. What is a constructor in Visual Basic?


a) A method that returns a value

b) A special type of function that is used to create objects from a class

c) A variable that stores information within a class

d) A keyword used to define the visibility of class members

Answer: b) A special type of function that is used to create objects from a class

20. What is the purpose of the "Me" keyword in Visual Basic?

a) To access the properties and methods of an instance of a class

b) To restrict access to class members

c) To define a new instance of a class

d) To create multiple instances of a class

Answer: a) To access the properties and methods of an instance of a class

You might also like