Site hosted by Angelfire.com: Build your free website today!


 

Quiz Two: Make Up Quiz

Name:


Background

Above you see two diagrams.  In each diagram, you see the identifiers "variable1" and "variable2".

Imagine the following function definition:

Function Example1(ByRef variable2 As Integer) As Integer
    Return 2 * Variable2
End Function

In the function definition above, you see the variable named "variable2".  As you can see, it is defined to be "by reference."  "variable2" is defined within the parameter list of the function "Example1".  Variables defined in the parameter list of a function are called "formal parameters."  Therefore, "variable2" is a formal parameter of the function "Example1" and its value is passed by reference.

Imagine the following snippet of code:

...
Dim variable1 As Integer
Dim variable3 As Integer

variable1 = 10
variable3 = Example1(variable1)
...

In the snippet of code above, "variable1" is a local variable.  "variable3" is another local variable, but plays no role in the question I will ask below.

The Question

(1)  Above you see two diagrams, A and B.  One of those diagrams is an accurate symbolic description of "variable1" and "variable2" inside of the body of "Example1" while "Example1" is executing during the call to "Example1" in the provided snippet of code.  The other diagram is not an accurate symbolic description of the same.  Which diagram accurately describes "variables1" and "variable2" inside the body of "Example1" while "Example1" is executing during the call to "Example1" in the provided snippet of code?  Circle one of the following two options:

A B
 

Background

In the diagram above, the boxes represent variables and the arrows represent copying values from one variable to another.  The labels on each array (e.g. "One", "Two" and "Three") indicate the sequence in which values are copied from one variable to another.

The Question

(2) In call we discussed a common procedure used in computation.  Which of the following names is a common name for that procedure.  Circle the correct answer:

(A) Bubble Sort

(B) Swap

(C) The Monkey Dance

(D) Min

(E) Max


Function Example2(ByVal intA As Integer, ByVal intB As Integer)As Integer
    If intA > intB Then
        Return intA
    Else
        Return intB
    End If
End Function

Background

Above you see a function named Example2.  Example2 takes two parameters, each an integer, and returns an integer.

For example:

Dim intFoo As Integer

intFoo = Example2(3, 2)

The Question

(3) When sentence best describes what Example2 does.  Circle the correct answer.

(A) Example2 returns the smallest of the two integers passed to it.

(B) Example2 always returns the value intB because the name "intB" is greater than the name "intA".

(C) Example2 returns the largest of the two integers passed to it.

(D) None of the above.


(4) Label, from left to right, with the left most being the smallest, the indices of the array below (e.g. put a number in each box indicating what the index of that box would be if the series of boxes were an array).