wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Inscoe - CPI 6.01-6.03

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

Which statement will correctly exit an application?

a)

Application.Close()

b)

Application.Exit()

c)

Stop()

d)

Exit()

2.

Given the output image in the figure shown, what event procedure was executed?

a)

Private Sub mnuGoodbye_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuGoodbye.Click

b)

Private Sub mnuHello_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuHello.Click

c)

Private Sub mnuProgram_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuProgram.Click

d)

Private Sub mnuClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuClose.Click

3.

Given the output image in the figure shown, what event procedure was executed?

a)

Private Sub mnuGoodbye_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuGoodbye.Click

b)

Private Sub mnuHello_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuHello.Click

c)

Private Sub mnuProgram_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuProgram.Click

d)

Private Sub mnuClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuClose.Click

4.

Which statement will correctly close a form?

a)

Application.Close()

b)

Application.Exit()

c)

Close()

d)

Me.Close()

5.

Which event should be used with a MenuStrip?

a)

.Changed

b)

.Selected

c)

.Click

d)

.CheckChanged

6.

Using the code segment below, what is the SelectedIndexvalue of Apple?


lstItems.Items.Add("Apple")

lstItems.Items.Add("Banana")

lstItems.Items.Add("Pear")

a)

0

b)

1

c)

2

d)

3

7.

In the figure shown, "Hello", "Goodbye", and "Close" are each an example of:

a)

a button.

b)

a menu tool strip item.

c)

a toolbar.

d)

a label.

8.

Using the code segment below, what is the SelectedIndexvalue of Pear?


lstItems.Items.Add("Apple")

lstItems.Items.Add("Banana")

lstItems.Items.Add("Pear")

a)

0

b)

1

c)

2

d)

3

9.

Which statement would be best to read input in from an InputBox into the numeric variable?

a)

dblNumerator= Convert.ToDouble(InputBox("Enter a numerator", "Numerator"))

b)

dblNumerator= InputBox("Enter a numerator", "Numerator")

c)

dblNumerator= Convert.ToInt32(InputBox("Enter a numerator", "Numerator"))

d)

Convert.ToDouble(InputBox("Enter a numerator", "Numerator"))= intNumerator

10.

The following statement displays a message box during run-time. Which of the arguments controls the title that displays on the top portion of the message box?


MessageBox.Show("Chloe did this correctly.", "Action correct?",MessageBoxButtons.OK, MessageBoxIcon.Question)

a)

Chloe did this correctly.

b)

Action correct?

c)

MessageBoxButtons.OK

d)

MessageBoxIcon.Question

11.

Which statement would correctly read input in from an InputBox into the string variable?

a)

strNumerator= InputBox("Enter a numerator", "Numerator")

b)

intNumerator= InputBox("Enter a numerator", "Numerator")

c)

strNumerator InputBox("Enter a numerator", "Numerator")

d)

InputBox("Enter a numerator", "Numerator")= strNumerator

12.

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

a)

If MessageBox.Show("Would you like to continue?", "Continue", MessageBoxButt ons.YesNo) = DialogResult.Yes

b)

If MessageBox.Show("Would you like to continue?", "Continue", MessageBoxButt ons.YesNo = OK)

c)

If MessageBox.Show("Would you like to continue?", "Continue", MessageBoxButt ons.YesNo) = Result.Yes

d)

If MessageBox.Show("Would you like to continue?", "Continue", MessageBoxButt ons.YesNo) = DialogResult.No

13.

Which TryParse is written correctly if an integer is to be entered from the TextBox called txtNumber into the variable intNumber ?

a)

blnAnswer= Int32(txtNumber.Text, intNumber)

b)

blnAnswer= Int.TryParse(txtNumber.Text, intNumber)

c)

blnAnswer= Int32.TryParse(txtNumber, intNumber)

d)

blnAnswer= Int32.TryParse(txtNumber.Text, intNumber)

14.

Which code segment will try to convert a string to an integer and return true or false if the conversion is successful?

a)

blnAnswer= Int32.Parse(intRate, strInput)

b)

blnAnswer= Int32.Parse(strInput, dblRate)

c)

blnAnswer= Int32.TryParse(strInput, intRate)

d)

blnAnswer= Int32.TryParse(intRate, strInput)

15.

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)

Two

b)

2

c)

0

d)

Enter numeric values.

16.

What is the result of the following code?


strNumEntered= "15"

Result= Int32.TryParse(strNumEntered, intTest)

a)

Result= True, intTest= 15

b)

Result= False, intTest= 15

c)

Result= False, intTest= 0

d)

Result= True, intTest= 0

17.

What is the result of the following code?


strNumEntered= "Five"

Result= Int16.TryParse(strNumEntered, intTest)

a)

Result= True, intTest= 5

b)

Result= False, intTest= 5

c)

Result= False, intTest= 0

d)

Result= True, intTest= 0

18.

Given the following block of code, what is the output if the value “.05” is entered?


If Int32.TryParse( txtRate.Text, intRate) Then MessageBox.Show("Your rate is: " & intRate.ToString("##.0%"))

MessageBox.Show("Enter numeric values.")

End If

a)

5

b)

5.0%

c)

0.05

d)

Enter numeric values.

19.

Given the following block of code, what is the output if the value “.05” is entered?


If Double.TryParse(txtRate.Text, dblRate) Then MessageBox.Show("Your rate is: " & dblRate.ToString("##.0%"))

Else MessageBox.Show("Enter numeric values.")

End If

a)

5

b)

5.0%

c)

0.05

d)

Enter numeric values.

20.

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

a)

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

b)

If TryParse. Double(dblNum, txtInput) Then

c)

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

d)

If TryParse(txtInput.Text, dblNum) Then