NEW
Font size
WorksheetsInscoe - CPI 7.01-7.04
Total questions: 30
Worksheet time: 15mins
Given the function header, which statement below is written to correctly call the function?
Function calcTotalPrice (ByVal dblPrice As Double, ByVal intQuantity As Integer) As Double
dblAnswer= calcTotalPrice(dblPrice, dblTaxRate, intQuantity)
dblAnswer (calcTotalPrice(intQuantity, dblPrice))
calcTotalPrice(intQuantity, dblPrice)
dblAnswer= calcTotalPrice(dblPrice, intQuantity)
Which For Each loop would correctly create a running total of the elements in an array called Scores?
For Each dblScore As Double in Scores
Total= Total + Scores(i)
Next dblScore
For Each...
Total=Total(i) + Scores(i)
Next dblScore
For Each dblScore As Double
Total= Total + Scores
Next dblScore
For Each dblScore As Double in Scores
Total= Total + dblScore
Next dblScore
Using the code shown, what is the value of dblResult after execution when 2.9 is entered into txtNum and 4 is entered into txtNum2?
7
There is an error and the program will not execute.
0
6.9
Using the code shown, what is the value of dblResult after execution when 2.9 is entered into txtNum and 4 is entered into txtNum2 ?
7
There is an error and the program will not execute.
0
6.9
In the code shown, what is the value of dblAnswer after the code executes?
0
10
20
30
What can be said of the following function procedure?
Private Function isPositive(ByVal intArg As Integer) As Boolean
If intArg <0 Then
Return False
Else
Return True
End If
End Function
The function can be used by any module.
The function returns a value having a data type of Boolean.
The function receives one argument having a data type of Boolean.
The function returns a value having a data type of Integer.
Given an array called intScores , which statement would pass the first element to the sub procedure below?
Private Sub GiveAdvice(ByVal intNum As Integer)
GiveAdvice(intScores())
GiveAdvice(intScores(0))
GiveAdvice(intScores(1))
GiveAdvice(intScores)
Given the following statements:
Dim strName As String= "6 + 7"
lblAnswer.Text= strName
What is displayed in the label?
Syntax Error
0
13
6 + 7
Which is the correct syntax to declare the heading of function CalcNum ?
Sub CalcNum (ByVal intNum1 As Integer, ByVal intNum2) As Integer
Function CalcNum (ByVal intNum1 As Integer, ByVal intNum2 As Integer)
Function CalcNum (ByRef intNum1 As Integer, ByVal intNum2 As Integer) As Integer
Function CalcNum (ByVal intNum1 As Integer, ByVal intNum2 As Integer) As Integer
In the code shown, what is the value of dblAnswer in btnAverage after the code executes?
0
10
20
30
What are the variables called that are shown in the procedure header for a sub procedure?
Arguments
Constants
Parameters
Values
Which assigns the value of 4 to the third element in an array named myPayArray ?
myPayArray(2)= 4
myPayArray(3)= 4
myPayArray(4)= 4
myPayArray(3)= 3
In the code shown, what is the value of dblAnswer in btnAverage after the code executes?
0
10
20
30
Given the following code, what is the value of strParent after execution?
Dim strParent As String= "Dad"
strParent= strParent.Replace("D", "L")
Dad
Dal
Lad
LaL
In the code shown, what is the value of dblAnswer in btnAverage after the code executes?
80
90
100
A syntax error will occur.
Given the following code, what is the value of strNew after execution?
Dim strWord As String= "Elephant"
Dim strNew As String
strNew= strWord.Insert(7, "s")
lblAnswer.Text= strNew
Elephants
Elephanst
Elephanss
There is an error and the code does not compile.
Which references the second element in the array named myArr?
myArr(0)
myArr(1)
myArr(2)
myArr(3)
Which function is used to convert a string entry in a textbox to a double number?
Convert.ToDouble(txtAge.Text)
Convert(txtAge.Text)
Convert.ToInt16(txtAge.Text)
Convert.ToInt32(txtAge.Text)
Which code segment would return the position number of the letter “m” in the string strName ?
strName.Index("m")
strName.Index(m)
strName.IndexOf("m")
strName.IndexOf(m)
Which best describes the purpose of function procedures?
Called from another procedure using the CALL statement
To alter arguments after they have been passed
To perform a specific task and then return one value
To perform several related tasks
Which of the code segments would display the following output?
You entered:Hello
Dim strFirst As String= "You entered: "
Dim strNext As String= " Hello "
Dim StrNew As String
strNew= strNext.TrimEnd
Me.lblDisplay.Text= strFirst & strNew
Dim strFirst As String= "You entered: "
Dim strNext As String= " Hello "
Dim strNew As String
strNew= strFirst.TrimEnd
Me.lblDisplay.Text= strFirst & strNew
Dim strFirst As String= "You entered: "
Dim strNext As String= " Hello "
Dim strNew As String
strNew= strNext.TrimStart
Me.lblDisplay.Text= strFirst & strNew
Dim strFirst As String= "You entered: "
Dim strNext As String= " Hello "
Dim strNew As String
strNew= strFirst.TrimStart
Me.lblDisplay.Text= strFirst & strNew
Given the following statements:
Dim intX As Integer= 0
Me.lblAnswer.Text= Math.Sign(intX)
What is displayed in the label?
intX
-1
0
1
Given a Dim statement of Dim strName(3) As Integer , which of the following elements are valid?
strName(-2)
strName(3)
strName(-3)
strName(4)
Given an array called intNumbers , which statement will get the number of elements in the array?
intLength= intNumbers.Size
intLength= intNumbers.Length
intLength= Length(intNumbers)
intLength= Array.SizeOf(intNumbers)
In the code shown, what is the value of dblResult after execution when 4 is entered into txtNum and 2.9 is entered into txtNum2 ?
7
There is an error and the program will not execute.
0
6.9
If 123.7894 is the number entered in a textbox, what will the following code display?
Dim dblNumber As Double= Convert.ToDouble(txtNumber.Text)
dblNumber= Math.Round(dblNumber, 1)
lblAnswer.Text= dblNumber.ToString()
123
123.7
123.8
124
Given the following code, what is the value of strAddress ?
Dim strStreet As String= "First"
Dim strCity As String= "Raleigh"
Dim strAddress As String
strAddress= String.Concat(strStreet, strCity)
lblDisplay.Text= stAddress
Raleigh First
First Raleigh
First Raleigh
FirstRaleigh
Given the following statements:
Dim intNumber As Integer= -10
Me.lblAnswer.Text= Math.Abs(intNumber)
What is displayed in the label?
-10
0
10
100
Which would correctly call the partial sub procedure defined below?
private Sub CalcTotalPrice (ByVal dblPrice As Double, ByVal intTaxRate As Integer, ByRef dblTotalPrice As Double)
Button_Click Local Variables
Dim dblPrice, dblTotalPrice As Double
Dim intTaxRate as Integer
CalcTotalPrice(dblPrice, intTaxRate, dblTotalPrice)
CalcTotalPrice(dblTotalPrice, intTaxRate, dblPrice)
CalcTotalPrice(dblPrice, dblTotalPrice, intTaxRate)
dblTotalPrice= CalcTotalPrice(dblPrice, intTaxRate)
In the code shown, what is the value of dblAnswer in btnAverage after the code executes?
102
104
100
An error will occur.
