Chapter 6 Review (ISCS 272) – Flashcards

Unlock all answers in this set

Unlock answers
question
Although you can omit the ByVal keyword in a parameter variable declaration, it is still a good idea to use it.
answer
True
question
A ________ is a special variable that receives a value being passed into a procedure or function.
answer
Parameter
question
Which of the following code examples is a function that will accept three Integer parameters, calculate their average, and return the result?
answer
Function Average(ByVal intX As Integer, ByVal IntY as Integer, _ ByVal intZ As Integer) As Single Return (intX + intY + intZ) / 3 End Function
question
All of the following are true about functions except ________.
answer
They can return one or more values
question
By writing your own procedures, you can ________ an applications code, that is, break it into small, manageable procedures.
answer
modularize
question
Which one of the following declarations uses Pascal casing for the procedure name?
answer
Sub MyProcedure() End Sub
question
Which statement is true in regard to passing an argument by value to a procedure?
answer
A copy of the argument is passed to the procedure.
question
A procedure may not be accessed by procedures from another class or form if the ________ access specifier is used.
answer
Private
question
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
answer
4
question
When a procedure finishes execution, ________.
answer
control returns to the point where the procedure was called and continues with the next statement
question
Which is the correct way to define a function named Square that receives an integer and returns an integer representing the square of the input value?
answer
Function Square(ByVal intNum as Integer) As Integer Return intNum * intNum End Function
question
What is the syntax error in the following procedure? Sub DisplayValue(Dim intNumber As Integer) MessageBox.Show(intNumber.ToString()) End Sub
answer
Dim is not valid when declaring parameters.
question
Which of the following procedures will keep track of the number of times it was called?
answer
Private Sub KeepTrack(ByRef intCount As Integer) intCount += 1 End Sub
question
What is wrong with the following GetName procedure? Sub GetName(ByVal strName As String) strName = InputBox("Enter your Name:") End Sub
answer
strName will be modified, but all changes will be lost when the procedure ends.
question
Which of the following functions accepts a parameter named dblSales and returns the commission to the calling statement? Assume that the commission should equal the sales multiplied by the commission rate. Use the following table as a guide to the calculation of the commission rate.Commission Rate Sales Commission Rate less than 2,000 10% 2,000 or more 15%
answer
Function Calc(ByVal dblSales As Double) As Double Dim dblRate As Double Select Case dblSales Case Is dblRate = .1 Case Is >= 2000 dblRate = .15 End Select Return dblRate * dblSales End Function
question
When debugging a program in break mode, the Step Into command causes the currently highlighted line of code to execute.
answer
True
question
When a parameter is declared using the ________ qualifier, the procedure has access to the original argument variable and may make changes to its value.
answer
ByRef
question
Which statement is not true regarding functions?
answer
The same function can return several data types including Integer, String, or Double.
question
What is incorrect about the following function? Function sum(ByVal intX As Integer, ByVal intY As Integer) As Integer Dim intAns As Integer intAns = intX + intY End Function
answer
the function does not return a value
question
Which of the following examples correctly uses an input box to assign a value to an integer, and returns the integer to the calling program using a reference parameter?
answer
Sub GetInput(ByRef intNumber As Integer) intNumber = CInt(InputBox("Enter an Integer")) End Sub
question
Which of the following calls to the GetNumber procedure is not valid? Sub GetNumber(ByVal intNumber as Integer) ' (procedure body) End Sub
answer
GetNumber(intX + 3, intY)
question
Which of the following can be returned by a function?
answer
All of the above
question
Which debugging command executes a function call without stepping through function's statements?
answer
Step Over
question
What will be the value of dblSum after the button btnAdd is clicked, assuming that 25 is entered by the user into txtNum1, and 35 is entered into txtNum2? Private Sub btnAdd_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnAdd.Click Dim dblNum1, dblNum2, dblSum As Double dblNum1 = CDbl(txtNum1.Text) dblNum2 = CDbl(txtNum2.Text) dblSum = Sum(dblNum1, dblNum2) lblSum.Text = dblSum.ToString() End Sub Function Sum(ByVal dblNum1 As Double, ByVal dblNum2 As Double) as Double Return dblNum1 + dblNum2 End Function
answer
60
question
Choose a new, more descriptive name for the WhatIsIt function based on the result of the code below. Function WhatIsIt(ByVal intRepeat as Integer) as Integer Dim intResult as Integer = 1 Dim intCount as Integer For intCount = 1 to intRepeat intResult = intResult * 2 Next intCount Return intResult End Function
answer
PowersOfTwo
question
When calling a procedure, passed arguments and declared parameters must agree in all of the following ways except ________.
answer
the names of the arguments and parameters must correspond
question
What is the value of intTotal after the following code executes? Dim intNumber1 As Integer = 2 Dim intNumber2 As Integer = 3 Dim intTotal As Integer intTotal = AddSquares(intNumber1, intNumber2) Function AddSquares(ByVal intA As Integer, ByVal intB As Integer) As Integer intA = intA * intA intB = intB * intB Return intA + intB intA = 0 intB = 0 End Function
answer
13
question
If you do not provide an access specifier for a procedure, it will be designated ________ by default.
answer
Public
Get an explanation on any task
Get unstuck with the help of our AI assistant in seconds
New