Unit 6 and 7 Review Flashcards

1
Q

What is the value of dblAnswer after the following code executes?
Private Sub btnAverage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAverage.Click
Dim dblNum1, dblNum2, dblNum3, dblAnswer As Double
dblNum1 = 10
dblNum2 = 20
dblNum3 = 30
FindAverage(dblNum1, dblNum2, dblNum3, dblAnswer)
End Sub
Private Sub FindAverage(ByVal dblNumber1 As Double, ByVal dblNumber2 As Double, ByVal dblNumber3 As Double, ByRef dblAns As Double)
dblAns = (dblNumber1 + dblNumber2 + dblNumber3) / 3
End Sub

A. 20
B. 30
C. 10
D. 0

A

A. 20

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Which would correctly call the sub procedure defined below?
Private Sub CalcTotalPrice (ByVal dblPrice As Double, ByVal intTaxRate As Integer,ByRef dblTotalPrice As Double)
A. dblTotalPrice = CalcTotalPrice(dblPrice, intTaxRate)
B. CalcTotalPrice(dblTotalPrice, intTaxRate, dblPrice)
C. CalcTotalPrice(dblPrice, intTaxRate, dblTotalPrice)
D. CalcTotalPrice(dblPrice, dblTotalPrice, intTaxRate)

A

C. CalcTotalPrice(dblPrice, intTaxRate, dblTotalPrice)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
Given the following statements:
    Dim intX As Integer = 0
    Me.lblAnswer.Text = Math.Sign(intX)
What is displayed in the label?
A. 1
B. 0
C. -1
D. intX
A

B. 0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the result of the following code?
strNumEntered = “Five”
Result = Int16.TryParse(strNumEntered, intTest)
A. Result = False, intTest = 5
B. Result = False, intTest = 0
C. Result = True, intTest = 0
D. Result = True, intTest = 5

A

B. Result = False, intTest = 0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
Assuming that a ListBox named lstAnswer exists, which statement correctly adds an item to the ListBox?
A. lstAnswer.Item.Add("Answer")
B. lstAnswer.AddItems("Answer")
C. lstAnswer.Items.Add = "Answer"
D. lstAnswer.Items.Add("Answer")
A

D. lstAnswer.Items.Add(“Answer”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Which event should be used with a MenuStrip?

A. .Click
B. Selected
C. Changed
D. .CheckChanged

A

A. .Click

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which best describes the purpose of function procedures?
A. To alter arguments after they have been passed
B. To perform a specific task and then return one value
C. They must be called from another procedure using the CALL statement
D. To perform several related tasks

A

B. To perform a specific task and then return one value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

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

A. Parameters
B. Constants
C. Arguments
D. Values

A

A. Parameters

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Which statement would correctly read input in from an InputBox into the string variable
A. strNumerator = InputBox(“Enter a numerator”, “Numerator”)
B. InputBox(“Enter a numerator”, “Numerator”) = strNumerator
C. intNumerator = InputBox(“Enter a numerator”, “Numerator”)
D. strNumerator InputBox(“Enter a numerator”, “Numerator”)

A

A. strNumerator = InputBox(“Enter a numerator

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Which segment of code will correctly test a Boolean expression to see if input from a TextBox can beconverted to an double?

A. If Double.TryParse(txtInput.Text, dblNum) Then
B. If TryParse. Double(dblNum, txtInput) Then
C. If TryParse(txtInput.Text, dblNum) Then
D. If TryParse. Double(txtInput.Text, dblNum) Then

A

A. If Double.TryParse(txtInput.Text, dblNum) Then

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Which is the correct syntax to declare the function CalcNum’s header?

A. Function CalcNum (ByVal intNum1 As Integer, ByVal intNum2 As Integer) As Integer
B. Sub CalcNum (ByVal intNum1 As Integer, ByVal intNum2) As Integer
C. Function CalcNum (ByRef intNum1 As Integer, ByVal intNum2 As Integer) As Intege
D. Function CalcNum (ByVal intNum1 As Integer, ByVal intNum2 As Integer)

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Which statement will return True if the user selects the Yes button of a Message Box?
Selected Answer:

A. If MessageBox.Show(“Would you like to continue?”, “Continue”,MessageBoxButtons.YesNo)=DialogResult.Yes
B. If MessageBox.Show(“Would you like to continue?”, “Continue”, MessageBoxButtons.YesNo) =Result.Yes
C. If MessageBox.Show(“Would you like to continue?”, “Continue”, MessageBoxButtons.YesNo = OK)
If MessageBox.Show(“Would you like to continue?”, “Continue”, MessageBoxButtons.YesNo) =DialogResult.No

A

A. If MessageBox.Show(“Would you like to continue?”, “Continue”,MessageBoxButtons.YesNo)=DialogResult.Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
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. calcTotalPrice(intQuantity, dblPrice)
B. dblAnswer = calcTotalPrice(dblPrice, dblTaxRate, intQuantity)
C. dblAnswer (calcTotalPrice(intQuantity, dblPrice))
D. dblAnswer = calcTotalPrice(intQuantity, dblPrice)
A

D. dblAnswer = calcTotalPrice(intQuantity, dblPrice)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q
Which correctly calls a function procedure?
A. Call Function (strGrade)
B. strGrade=GPA(numDouble )
C. Call GPA() Function
D. Function = GPA( )
A

B. strGrade=GPA(numDouble )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the value of dblGPA after the following statement executes if the value 3.10 is entered into theTextBox?
blnAnswer = Double.TryParse(txtGPAInput.Text, dblGPA)
A. There is not enough information to determine.
B. 3.1
C. “3.10”
D. 0

A

B. 3.1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

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

A. strName.IndexOf(“m”)
B. strName.Index(“m”)
C. strName.IndexOf(m)
D. strName.Index(m)

A

A. strName.IndexOf(“m”)

17
Q
Which declares an integer array with 4 elements?
A. Dim myArray(4) Integer
B. Dim myArray(3) As Integer
C. As Integer Declare myArray(4)
D. Declare Array As Integer myArray(4)
A

B. Dim myArray(3) As Integer

18
Q

Given the following block of code, what is the output if the value “two” is entered?
If Int16.TryParse( txtNum.Text, intNum) Then
intNum = Convert.ToInt16(txtNum.Text) MessageBox.Show(“Your number is: & intNum.ToString)
Else MessageBox.Show(“Enter numeric values.”)
End If

A. Enter numeric values.
B. 2
C. Two
D. 0

A

A. Enter numeric

19
Q
Which code would be used to display a message box on a form?
A. Display("String")
B. Display("String")
C. ShowMessage("String")
D. MessageBox.Show("String")
A

D. MessageBox.Show(“String”)

20
Q

Using the code segment below, what is the SelectedIndex value of Apple?
lstItems.Items.Add(“Apple”)
lstItems.Items.Add(“Banana”)
lstItems.Items.Add(“Pear”)

A. 0
B. 1
C. 2
D. 3

A

A. 0

21
Q

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. Lad
C. LaL
D. Dal

A

B. Lad

22
Q

What is the result of the following code?
strNumEntered = “45”
Result = Int32.TryParse(strNumEntered, intTest)
A. Result = True, intTest = 0
B. Result = True, intTest = 45
C. Result = False, intTest = 0
D. Result = False, intTest = 45

A

B. Result = True, intTest = 45

23
Q

Which statement correctly creates and initializes the array?
A. Dim dblQuiz() As Double = (96.5, 87.6, 87.4, 92.8)
B. Dim dblQuiz(3) As Double = {96.5, 87.6, 87.4, 92.8}
C. Dim dblQuiz() As Double = {96.5, 87.6, 87.4, 92.8}
D. Dim dblQuiz(3) As Double = (96.5, 87.6, 87.4, 92.8)

A

C. Dim dblQuiz() As Double = {96.5, 87.6, 87.4, 92.8}

24
Q
Which function is used to convert a string entry in a textbox to a double number?
A. Convert(txtAge.Text)
B. Convert.ToInt32(txtAge.Text)
C. Convert.ToInt16(txtAge.Text)
D. Convert.ToDouble(txtAge.Text)
A

D. Convert.ToDouble(txtAge.Text)