CIS3309: Component-Based Software Development

Spring 2012

Quiz 3

Name:

1.  TRUE or FALSE: the elements stored in an array don’t have to be the same data-type.

2.  How is an Array different from an ArrayList?

3.  Give an example of declaring an array to hold 3 Integer values, and store the values in the array once it has been declared. You may use either an Array or ArrayList.

4.  What is the purpose of the Redim statement?

5.  Explain the differences between parameters declared as ByVal and ByRef in a procedure’s parameter list?

6.  What is the major difference between a Sub procedure and a Function procedure?

Use the following code to answer questions 7 – 9.

Function Convert(ByVal conversionType As String, ByRef value As Double) As Integer

Select Case conversionType

Case “KM”, “km”

value = value / 1.609

Case “MK”, “mk”

value = value * 1.609

Else Case

Return -1

End Select

Return 0

End Function

Dim miles As Double = 10

Dim str As String = “MK”

Dim result As Double = 0

result = Convert(str, miles)

7.  What is the value of the variable result after the following code is executed?

8.  What is the value of the variable str before the call to the Convert() function? What is the value of the variable str after the call to the Convert() function?

9.  What is the value of the variable miles before the call to the Convert() function? What is the value of the variable miles after the call to the Convert() function?

10.  Which of the following statements is True about parameters designated as Optional?

(circle all the apply)

a.  All the parameters designated as optional must be given an initial value.

b.  Parameters that are designated as optional must come before all other parameters in the parameter list.

c.  Specifying optional parameters for a procedure is an alternative to procedure overloading.

d.  All optional parameters must be designated as ByVal.