1. (TCO 8) When we pass a variable by reference, any changes that the procedure makes to the variable will _____. 

change the value in the original variable

change the value inside the called function/sub procedure only

change the address of the variable

not make any significant changes

 

2. (TCO 8) What is wrong with the following call statement and its corresponding sub statement? 

Call Statement: 

DayOfTheWeek(15, "June", 1902)

Sub Statement:

Sub DayOfTheWeek(ByVal var1 As Integer, ByVal var2 As String, ByVal var3 As String) 

Constant values like 1902 cannot be passed, only variables.

It is not valid to pass a value like "June."

var3 is not of the same data type as 1902.

Nothing is wrong with them.

 

3. (TCO 8) What changes are required in the following code so that the resulting output is as follows?

Expected Output:

num1 = 17

num2 = 7

Code: Sub Main()

Dim num1 As Integer = 16

Dim num2 As Integer = 6

AddOne(num1)

AddOne(num2)

Console.WriteLine("num1 = " & num1)

Console.WriteLine("num2 = " & num2)

End Sub

Sub AddOne(ByVal x As Integer)

x = x + 1

End Sub 

Change function declaration to: XXX XXXXXX(ByRef x As Integer).

Change function declaration to: XXX XXXXXX (ByVal x As Integer) As Integer.

Change function declaration to: XXX XXXXXX (ByRef x As Integer) As Integer.

No changes are required, the function works as expected.

 

4. (TCO 8) What is displayed when the following code is executed?

Sub Main()

Dim a, b As String

Dim x As Integer = 0

a = "How now brown cow."

b = "brown"

x = FindIt(a, b)

System.Console.WriteLine(x.ToString())

End Sub

Function FindIt(ByVal z1 As String, ByVal z2 As String) As Integer

Dim x As Integer

x = z1.IndexOf(z2)

End Function 

8"How now"

An error

None of the above

 

    • 12 years ago
    A+ Answers
    NOT RATED

    Purchase the answer to view it

    • 37.doc