250+ TOP MCQs on Passing Variables and Answers

Visual Basic Multiple Choice Questions on “Passing Variables”.

1. Every variable has both a value and _____________
a) Unique address
b) Value
c) Name
d) Relative address

Answer: a
Clarification: Every variable has both a value and a unique address that represents its location in the computer’s internal memory. Visual Basic allows you to pass either a copy of the variable’s value or the variable’s address to the receiving procedure.

2. Passing a copy of the variable is referred to as _____________________
a) Pass by value
b) Pass by address
c) Pass by reference
d) Pass by pointer

Answer: a
Clarification: Passing a copy of the variable’s value is referred to as passing by value. Passing a variable’s address is referred to as passing by reference. The method you choose—by value or by reference—depends on whether you want the receiving procedure to have access to the variable in memory. In other words, it depends on whether you want to allow the receiving procedure to change the variable’s contents.

3. Passing a variable’s address is referred to as _____________________
a) Pass by value
b) Pass by address
c) Pass by reference
d) Pass by pointer

Answer: c
Clarification: Passing a copy of the variable’s value is referred to as passing by value. Passing a variable’s address is referred to as passing by reference. The method you choose—by value or by reference—depend on whether you want the receiving procedure to have access to the variable in memory. In other words, it depends on whether you want to allow the receiving procedure to change the variable’s contents.

4. To pass a variable by value, you include the keyword ________________ before the name of its corresponding parameter.
a) ByVal
b) Val
c) PassVal
d) Pass

Answer: a
Clarification: To pass a variable by value, you include the keyword ByVal before the name of its corresponding parameter in the receiving procedure’s parameter list. When you pass a variable by value, the computer passes a copy of the variable’s contents to the receiving procedure. When only a copy of the contents is passed, the receiving procedure is not given access to the variable in memory. Therefore, it cannot change the value stored inside the variable. It is appropriate to pass a variable by value when the receiving procedure needs to know the variable’s contents, but it does not need to change the contents. Unless you specify otherwise, variables in Visual Basic are automatically passed by value.

5. The ___________statement does not indicate whether a variable is passed by value or by reference.
a) Call
b) Parameter
c) Function
d) Declaration

Answer: a
Clarification: The Call statement does not indicate whether a variable is being passed by value or by reference. To make that determination, you need to look at the receiving procedure’s header.

6. The position of an item in a list box depends on the value stored in the list box’s ____________________
a) Ascending property
b) Descending Property
c) Sorted property
d) Unsorted property

Answer: c
Clarification: The position of an item in a list box depends on the value stored in the list box’s Sorted property. When the Sorted property is set to False (the default value), the item is added at the end of the list. When the Sorted property is set to True, the item is sorted along with the existing items and then placed in its proper position in the list. Visual Basic sorts the list box items in dictionary order, which means that numbers are sorted before letters, and a lowercase letter is sorted before its uppercase equivalent.

7. The items in a list box are sorted based on the ___________ characters in each item.
a) Leftmost
b) Rightmost
c) Previous
d) Next

Answer: a
Clarification: The items in a list box are sorted based on the leftmost characters in each item. As a result, the items “Personnel”, “Inventory”, and “Payroll” will appear in the following order when the control’s Sorted property is set to True: Inventory, Payroll, Personnel. Likewise, the items 1, 2, 3, and 10 will appear in the following order when the control’s Sorted property is set to True: 1, 10, 2, 3.

8. The ___________ keyword tells the computer to pass the variable’s address rather than its contents.
a) ByRef
b) ByVal
c) ByAdd
d) ByPoint

Answer: a
Clarification: You pass a variable by reference when you want the receiving procedure to change the contents of the variable. To pass a variable by reference in Visual Basic, you include the keyword ByRef before the name of its corresponding parameter in the receiving procedure’s header. The ByRef keyword tells the computer to pass the variable’s address rather than its contents.

9. The items listed in the Call statement are referred to as ____________________
a) Arguments
b) Parameters
c) Passers
d) Callers

Answer: a
Clarification: The items listed in the Call statement are referred to as arguments; and the items listed in the calling statement are referred to as parameters.

10. Which of the following is false?
a) A function can return one or more values to the statement that invoked it
b) A procedure can accept one or more items of data passed to it
c) The parameter List in a procedure header is optional
d) At times, a memory location inside the computer’s internal memory may have more than one name

Answer: a
Clarification: A function can return only one value to the statement that invoked it. Since return statement is the last statement of any function.

Leave a Reply

Your email address will not be published. Required fields are marked *