This set of Visual Basic Multiple Choice Questions & Answers (MCQs) focuses on “Function Procedures”.
1. _____________________ returns a value after performing its specific task.
a) Function Procedure
b) Sub procedure
c) Sub block
Explanation: In addition to creating Sub procedures in Visual Basic, you also can create
Function procedures. The difference between both types of procedures is that a Function procedure returns a value after performing its assigned task, whereas a Sub procedure does not return a value. Function procedures are referred to more simply as functions.
2. The functions header and footer contains the _______________ keyword.
Explanation: The header and footer in a function are almost identical to the header and footer in a Sub procedure, except the function’s header and footer contain the Function keyword rather than the Sub keyword.
3. A function’s header includes the ___________ data type.
Explanation: A Sub procedure’s header does not contain a data type since it does not return any value. Different from a Sub procedure header a function’s header includes the As dataType section, which specifies the data type of the value returned by the function.
4. A function can receive information either by value or by _________________
Explanation: As is true with a Sub procedure, a function can receive information either by value or by reference. The information it receives is listed in the parameterList in the header.
5. Between the function’s _____________ and ___________________ you enter the instructions to process when the function is invoked.
a) Header and footer
b) Parameters and arguments
c) Call and return
d) Return type and function name
Explanation: Between the function’s header and footer, you enter the instructions to process when the function is invoked. It is called the function body. It performs the task that the function need to perform, and returns the appropriate result.
6. ________________ statement is the last statement in the function.
Explanation: In most cases, the Return statement is the last statement within a function. The statement’s syntax is Return expression, where expression represents the one and only value that will be returned to the statement invoking the function. The data type of the expression must agree with the data type specified in the As dataType section of the header.
7. Each memory location listed in the parameterList in the procedure header is referred to as _________________
a) an address
b) a constraint
c) a parameter
d) a value
Explanation: Each memory location listed in the parameterList in the procedure header is referred to as a parameter. It receives the value passed by the arguments during the function call.
8. To determine whether a variable is being passed to a procedure by value or by reference, you will need to examine ________________
a) the Call statement
b) the procedure header
c) the statements entered in the procedure
d) the procedure footer
Explanation: To determine whether a variable is being passed to a procedure by value or by reference, you will need to examine the Call statement. In the Call statement examining the arguments we can say whether we have passed by value or by reference.
9. Which of the following is false?
a) The sequence of the arguments listed in the Call statement should agree with the sequence of the parameters listed in the receiving procedure’s header.
b) The data type of each argument in the Call statement should match the data type of its corresponding parameter in the procedure header.
c) The name of each argument in the Call statement should be identical to the name of its corresponding parameter in the procedure header.
d) When you pass information to a procedure by value, the procedure stores a copy of each value it receives in a separate memory location.
Explanation: The name of each argument in the Call statement may not be identical to the name of its corresponding parameter in the procedure header. Since when you call by value, the variables name may differ.
10. Which of the following instructs a function to return the contents of the decStateTax variable?
a) Return decStateTax
b) Return ByVal decStateTax
c) Send decStateTax
d) SendBack decStateTax
Explanation: Return decStateTax returns the value of the decStateTax, and it should be the last statement of the function. We do not need Byval here, it is only required, in the Call statement, when the function is called.
Sanfoundry Global Education & Learning Series – Visual Basic.
To practice all areas of Visual Basic, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Practice Computer Science MCQs
- Buy Visual Basic Books
- Apply for Visual Basic Internship
- Buy Computer Science Books
- Apply for Computer Science Internship