Filters
Question type

Study Flashcards

Which statement is not true regarding functions?


A) A function is a self-contained set of statements that can receive input values.
B) Visual Basic has many built-in functions such as CSng(txtInput.Text)
C) A function can only return a single value.
D) The same function can return several data types including integer, string, or double

E) None of the above
F) B) and C)

Correct Answer

verifed

verified

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


A) 60
B) 50
C) 0
D) 70

E) A) and C)
F) A) and B)

Correct Answer

verifed

verified

What is wrong with the following GetName procedure? Sub GetName(ByVal strName As String) StrName = InputBox("Enter your Name:") End Sub


A) The procedure is missing a Return statement.
B) GetName is a reserved word and cannot be used as a name of a procedure.
C) strName will be modified, but all changes will be lost when the procedure ends.
D) The syntax for the call to InputBox is incorrect.

E) A) and C)
F) C) and D)

Correct Answer

verifed

verified

If we were to call the MakeDouble and ChangeArg methods shown below, using the following statements, what value would be assigned to lblResult.Text? Dim intValue As Integer = 20 ChangeArg(intValue) LblResult.Text = MakeDouble(intValue) .ToString() Function MakeDouble (ByVal intArg As Integer) As Integer Return intArg * 2 End Function Sub ChangeArg2(ByRef intArg As Integer) ' Display the value of intArg. LstOutput.Items.Add(" ") LstOutput.Items.Add("Inside the ChangeArg procedure, " & "intArg is " & intArg.ToString() ) LstOutput.Items.Add("I will change the value of intArg.") ' Assign 0 to intArg. IntArg = 0 ' Display the value of intArg. LstOutput.Items.Add("intArg is now " & intArg.ToString() ) LstOutput.Items.Add(" ") End Sub


A) 0
B) 20
C) 40
D) (cannot be determined)

E) All of the above
F) B) and C)

Correct Answer

verifed

verified

Although you can omit the ByVal keyword in a parameter variable declaration, it is still a good idea to use it.

A) True
B) False

Correct Answer

verifed

verified

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?


A) Function Square(ByVal intNum as Integer) As Integer Return
intNum * intNum
End Function

B) Function Square(ByVal intNum as Integer)
Return intNum * intNum
End Function

C) Function Square(ByVal intNum as Integer) As Double
Return intNum * intNum
End Function

D) Function Square(ByVal intNum as Integer) As Double
Dim dblAns as Double
DblAns = intNum * intNum
Return dblAns
End Function

E) C) and D)
F) B) and C)

Correct Answer

verifed

verified

When debugging a program in break mode, the Step Into command causes the currently highlighted line of code to execute.

A) True
B) False

Correct Answer

verifed

verified

When a procedure finishes execution, __________.


A) control returns to the point where the procedure was called and continues with the next statement
B) the application terminates unless the procedure contains a Return statement
C) control transfers to the next procedure found in the code
D) the application waits for the user to trigger the next event

E) None of the above
F) All of the above

Correct Answer

verifed

verified

Which of the following does not apply to procedures and functions?


A) they help to break up a large body of code into smaller chunks
B) they make it easier to maintain and modify code
C) the execution time is significantly reduced by calling procedures and functions
D) they permit the same sequence of code statements to be called from multiple places

E) A) and B)
F) All of the above

Correct Answer

verifed

verified

Which one of the following declarations uses Pascal casing for the procedure name?


A) Sub MyProcedure()
End Sub
B) Sub myprocedure()
End Sub
C) Sub my_procedure()
End Sub
D) Sub myProcedure()
End Sub

E) A) and B)
F) A) and D)

Correct Answer

verifed

verified

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


A) intAns should not be declared inside the Function.
B) the as Integer at the end of the Function heading should be eliminated.
C) the function does not return a value
D) parameters intA and intB should be declared as ByRef

E) All of the above
F) A) and B)

Correct Answer

verifed

verified

Showing 21 - 31 of 31

Related Exams

Show Answer