wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Inscoe - CPI 7.01-7.04

Total questions: 30

Worksheet time: 15mins

Name
Class
Date
1.

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

a)

dblAnswer= calcTotalPrice(dblPrice, dblTaxRate, intQuantity)

b)

dblAnswer (calcTotalPrice(intQuantity, dblPrice))

c)

calcTotalPrice(intQuantity, dblPrice)

d)

dblAnswer= calcTotalPrice(dblPrice, intQuantity)

2.

Which For Each loop would correctly create a running total of the elements in an array called Scores?

a)

For Each dblScore As Double in Scores

Total= Total + Scores(i)

Next dblScore

b)

For Each...

Total=Total(i) + Scores(i)

Next dblScore

c)

For Each dblScore As Double

Total= Total + Scores

Next dblScore

d)

For Each dblScore As Double in Scores

Total= Total + dblScore

Next dblScore

3.

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?

a)

7

b)

There is an error and the program will not execute.

c)

0

d)

6.9

4.

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 ?

a)

7

b)

There is an error and the program will not execute.

c)

0

d)

6.9

5.

In the code shown, what is the value of dblAnswer after the code executes?

a)

0

b)

10

c)

20

d)

30

6.

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

a)

The function can be used by any module.

b)

The function returns a value having a data type of Boolean.

c)

The function receives one argument having a data type of Boolean.

d)

The function returns a value having a data type of Integer.

7.

Given an array called intScores , which statement would pass the first element to the sub procedure below?


Private Sub GiveAdvice(ByVal intNum As Integer)

a)

GiveAdvice(intScores())

b)

GiveAdvice(intScores(0))

c)

GiveAdvice(intScores(1))

d)

GiveAdvice(intScores)

8.

Given the following statements:

Dim strName As String= "6 + 7"

lblAnswer.Text= strName


What is displayed in the label?

a)

Syntax Error

b)

0

c)

13

d)

6 + 7

9.

Which is the correct syntax to declare the heading of function CalcNum ?

a)

Sub CalcNum (ByVal intNum1 As Integer, ByVal intNum2) As Integer

b)

Function CalcNum (ByVal intNum1 As Integer, ByVal intNum2 As Integer)

c)

Function CalcNum (ByRef intNum1 As Integer, ByVal intNum2 As Integer) As Integer

d)

Function CalcNum (ByVal intNum1 As Integer, ByVal intNum2 As Integer) As Integer

10.

In the code shown, what is the value of dblAnswer in btnAverage after the code executes?

a)

0

b)

10

c)

20

d)

30

11.

What are the variables called that are shown in the procedure header for a sub procedure?

a)

Arguments

b)

Constants

c)

Parameters

d)

Values

12.

Which assigns the value of 4 to the third element in an array named myPayArray ?

a)

myPayArray(2)= 4

b)

myPayArray(3)= 4

c)

myPayArray(4)= 4

d)

myPayArray(3)= 3

13.

In the code shown, what is the value of dblAnswer in btnAverage after the code executes?

a)

0

b)

10

c)

20

d)

30

14.

Given the following code, what is the value of strParent after execution?


Dim strParent As String= "Dad"

strParent= strParent.Replace("D", "L")

a)

Dad

b)

Dal

c)

Lad

d)

LaL

15.

In the code shown, what is the value of dblAnswer in btnAverage after the code executes?

a)

80

b)

90

c)

100

d)

A syntax error will occur.

16.

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

a)

Elephants

b)

Elephanst

c)

Elephanss

d)

There is an error and the code does not compile.

17.

Which references the second element in the array named myArr?

a)

myArr(0)

b)

myArr(1)

c)

myArr(2)

d)

myArr(3)

18.

Which function is used to convert a string entry in a textbox to a double number?

a)

Convert.ToDouble(txtAge.Text)

b)

Convert(txtAge.Text)

c)

Convert.ToInt16(txtAge.Text)

d)

Convert.ToInt32(txtAge.Text)

19.

Which code segment would return the position number of the letter “m” in the string strName ?

a)

strName.Index("m")

b)

strName.Index(m)

c)

strName.IndexOf("m")

d)

strName.IndexOf(m)

20.

Which best describes the purpose of function procedures?

a)

Called from another procedure using the CALL statement

b)

To alter arguments after they have been passed

c)

To perform a specific task and then return one value

d)

To perform several related tasks

21.

Which of the code segments would display the following output?


You entered:Hello

a)

Dim strFirst As String= "You entered: "

Dim strNext As String= " Hello "

Dim StrNew As String

strNew= strNext.TrimEnd

Me.lblDisplay.Text= strFirst & strNew

b)

Dim strFirst As String= "You entered: "

Dim strNext As String= " Hello "

Dim strNew As String

strNew= strFirst.TrimEnd

Me.lblDisplay.Text= strFirst & strNew

c)

Dim strFirst As String= "You entered: "

Dim strNext As String= " Hello "

Dim strNew As String

strNew= strNext.TrimStart

Me.lblDisplay.Text= strFirst & strNew

d)

Dim strFirst As String= "You entered: "

Dim strNext As String= " Hello "

Dim strNew As String

strNew= strFirst.TrimStart

Me.lblDisplay.Text= strFirst & strNew

22.

Given the following statements:

Dim intX As Integer= 0

Me.lblAnswer.Text= Math.Sign(intX)


What is displayed in the label?

a)

intX

b)

-1

c)

0

d)

1

23.

Given a Dim statement of Dim strName(3) As Integer , which of the following elements are valid?

a)

strName(-2)

b)

strName(3)

c)

strName(-3)

d)

strName(4)

24.

Given an array called intNumbers , which statement will get the number of elements in the array?

a)

intLength= intNumbers.Size

b)

intLength= intNumbers.Length

c)

intLength= Length(intNumbers)

d)

intLength= Array.SizeOf(intNumbers)

25.

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 ?

a)

7

b)

There is an error and the program will not execute.

c)

0

d)

6.9

26.

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()

a)

123

b)

123.7

c)

123.8

d)

124

27.

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

a)

Raleigh First

b)

First Raleigh

c)

First Raleigh

d)

FirstRaleigh

28.

Given the following statements:


Dim intNumber As Integer= -10

Me.lblAnswer.Text= Math.Abs(intNumber)


What is displayed in the label?

a)

-10

b)

0

c)

10

d)

100

29.

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

a)

CalcTotalPrice(dblPrice, intTaxRate, dblTotalPrice)

b)

CalcTotalPrice(dblTotalPrice, intTaxRate, dblPrice)

c)

CalcTotalPrice(dblPrice, dblTotalPrice, intTaxRate)

d)

dblTotalPrice= CalcTotalPrice(dblPrice, intTaxRate)

30.

In the code shown, what is the value of dblAnswer in btnAverage after the code executes?

a)

102

b)

104

c)

100

d)

An error will occur.