Visual Basic Questions and Answers – Function Procedures

«
»

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
d) Structure
View Answer

Answer: a
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.
advertisement

2. The functions header and footer contains the _______________ keyword.
a) Function
b) Struct
c) Sub
d) Class
View Answer

Answer: a
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.
a) As
b) To
c) From
d) By
View Answer

Answer: a
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 _________________
a) Reference
b) Address
c) Pointer
d) Value
View Answer

Answer: a
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
View Answer

Answer: a
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.
advertisement

6. ________________ statement is the last statement in the function.
a) Footer
b) Header
c) Return
d) Call
View Answer

Answer: c
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
View Answer

Answer: c
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
View Answer

Answer: a
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.
View Answer

Answer: c
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.
advertisement

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
View Answer

Answer: a
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.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

advertisement
advertisement
advertisement
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn