Function Procedures - Visual Basic Questions and Answers

1.

_________________ returns a value after performing its specific task.

   A.) Function Procedure
   B.) Sub procedure
   C.) Structure
   D.) Sub block

Answer: Option 'A'

Function Procedure
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.

DigitalOcean Referral Badge

2.

The functions header and footer contains the _______________ keyword.

   A.) Sub
   B.) Function
   C.) Class
   D.) Struct

Answer: Option 'B'

Function

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.

DigitalOcean Referral Badge

3.

A function’s header includes the ___________ data type.

   A.) As
   B.) From
   C.) By
   D.) To

Answer: Option 'A'

As
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.

DigitalOcean Referral Badge

4.

A function can receive information either by value or by _________________

   A.) Reference
   B.) Address
   C.) Value
   D.) Pointer

Answer: Option 'A'

Reference
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.

DigitalOcean Referral Badge

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

Answer: Option 'A'

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.

DigitalOcean Referral Badge

6.

________________ statement is the last statement in the function.

   A.) Footer
   B.) Header
   C.) Return
   D.) Call

Answer: Option 'C'

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.

DigitalOcean Referral Badge

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

Answer: Option 'C'

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.

DigitalOcean Referral Badge

8.

To determine whether a variable is being passed to a procedure by value or by reference, you will need to examine ________________

   A.) the procedure header
   B.) the Call statement
   C.) the procedure footer
   D.) the statements entered in the procedure

Answer: Option 'A'

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.

DigitalOcean Referral Badge

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.

Answer: Option 'C'

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.

DigitalOcean Referral Badge

10.

Which of the following instructs a function to return the contents of the decStateTax variable?

   A.) Return decStateTax
   B.) Send decStateTax
   C.) SendBack decStateTax
   D.) Return ByVal decStateTax

Answer: Option 'A'

Return decStateTax

DigitalOcean Referral Badge

Function Procedures - Visual Basic Questions and Answers Download Pdf

Recent Posts