This preview has intentionally blurred parts. Sign up to view the full document

View Full Document

Unformatted Document Excerpt

Chapter 6 ____ 1. If you want to prevent statements from outside a form from accessing a procedure, you set the access specifier to in the procedures declaration. a. Private b. Public c. Static d. Scope ____ 2. If a procedure is called more than once in a program, the values stored in the procedures local variables will persist only if declared with the keyword. a. Const b. Public c. Static d. Dim ____ 3. A is a special variable in a Sub or Function heading that receives an arguments value/address from a calling procedure. a. temporary variable b. constant c. original argument d. parameter ____ 4. Which one of the given procedure calls does not pass in valid arguments to the following GetANumber sub- procedure? Sub GetANumber(ByVal intNumber as Integer) ' (procedure body) End Sub a. GetANumber(intX) b. GetANumber(3 + 5 * 8 + intX) c. GetANumber(intX + 3, intY) d. GetANumber(Cint(txtNumber.Text)) ____ 5. When calling a procedure, the passed arguments and the declared parameters must agree in all of the follow- ing ways except one of the following. a. The order of arguments and parameters must correspond b. The names of the arguments and parameters must correspond c. The types of the arguments and parameters must correspond d. the number of arguments and the number of parameters must be the same 38 ____ 6. Which of the following code examples is a correctly written function that will accept three integer parameters, calculate their average, and return the result? a. Private Function Average(intX As Integer, intY As Integer, _ int Z As Integer) As Single Average = (intX + intY + intZ) / 3 End Function b. Private Function Average(ByVal intX As Integer, ByVal intY _ As Integer, ByVal intZ As Integer) As Single Average = intX + intY + intZ / 3 Return Average End Function c. Private Function Average(ByRef intX As Integer, _ ByRef intY As Integer, ByRef intZ As Integer, ByRef Average _ As Double) Average = (intX + intY + intZ) / 3 End Function d. Private Function Average (ByVal intX As Integer, _ ByVal intY As Integer, ByVal intZ As Integer) As Single Return (intX + intY + intZ) / 3 End Function ____ 7. What is incorrect about the following function? Public Function sum(ByVal intX As Integer, ByVal intY As Integer) As Integer Dim intAns As Integer intAns = intX + intY End Function a. intAns should not be declared inside the Function b. the Function heading should be replaced with: sum(ByVal intX As Integer, ByVal intY As Integer, _ ByRef intAns As Integer ) c. the function does not return a value d. parameters intA and intB should be ByRef parameters 39 ____ 8. What is assigned to lblDisplay.Text when the following code executes? Dim intNumber As Integer = 4 AddOne(intNumber, 6) lblDisplay.Text = intNumber ' Code for AddOne Public Sub AddOne(ByVal intFirst As Integer, ByVal intSecond As Integer) intFirst += 1 intSecond += 1 End Sub a. 4 b. 5 c. 6 d. 7 ____ 9. What is the value of intTotal after the following code executes?... View Full Document

End of Preview

Sign up now to access the rest of the document