Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts

Consider the following event procedure that calls a Function procedure named Cube, which returns the cube of a number. Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim num, result As Double num = CDbl(InputBox("Enter a number to cube:")) result = Cube(num) txtBox.Text = "The cube of " & num & " is " & result & "." End Sub Which of the following is a correct Function definition for Cube?

Consider the following event procedure that calls a Function procedure named Cube, which
returns the cube of a number.
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim num, result As Double
num = CDbl(InputBox("Enter a number to cube:"))
result = Cube(num)
txtBox.Text = "The cube of " & num & " is " & result & "."
End Sub
Which of the following is a correct Function definition for Cube?


1. Function Cube(var As Double) As Double
Return var ^ 3
End Function
2. Function Cube(num As Double) As Double
Return num ^ 3
End Function


(A) 1 only
(B) 2 only
(C) Both 1 and 2
(D) Neither 1 nor 2



Answer: C

Which statement is True in regard to the following code?

Which statement is True in regard to the following code?



A) This is an infinite loop.
B) intCount should start at -1.
C) The Items.Insert method should be used instead of Items.Add.
D) The text Good Job should not have quotation marks around it.


Correct Answer(s): A

What is wrong with the following code?

What is wrong with the following code?



A) The Next statement must read Next intIndex.
B) A For Next loop cannot be used to count backward.
C) intIndex is declared incorrectly for use with this type of loop.
D) You need to specify a negative step value in order to execute this loop.


Correct Answer(s): D

A difference between a ListBox and a drop-down ComboBox is __

A difference between a ListBox and a drop-down ComboBox is ________.

A) a ListBox takes up less room on the form
B) a ComboBox allows the user to enter text other than what is already in the List
C) a ListBox allows the user to enter text other than what is already in the List
D) there is no difference


Correct Answer(s): B

The SelectedItem property of a ListBox____.

The SelectedItem property of a ListBox____.

A) contains the index of the currently selected item
B) contains the text of the currently selected item
C) returns the location of the currently selected item
D) returns -1 if no item is selected


Correct Answer(s): B

What is the difference in the execution of the Do Until Loop (first example) and the Do Loop Until (second example)?

What is the difference in the execution of the Do Until Loop (first example) and the Do Loop Until (second example)?


A) Both loops are executed in an identical manner.
B) The first loop will never be executed while the second loop will execute once.
C) The first loop will execute one more time than the second loop.
D) The first loop will never be executed while the second is an infinite loop.


Correct Answer(s): D

In the following statement that begins a For Next loop, what is the purpose of the Step clause?

In the following statement that begins a For Next loop, what is the purpose of the Step clause?


For intX = 1 to 100 Step 5
A) It causes intX to be initialized to 5 when the loop begins.
B) It causes the loop to end when intX is equal to 5.
C) It causes intX to be incremented by 5 each time the loop repeats.
D) It causes intX to be decremented by 5 each time the loop repeats.



Correct Answer(s): C

Which statement about the ListBox.Add method is true?

Which statement about the ListBox.Add method is true?

A) It will always place the item at the end of the list.
B) It can be used to place an item anywhere in the list.
C) It finds the sum of all of the items in the list .
D) It always puts the item at the beginning of the list.



Correct Answer(s): A

What is the difference in execution between the two following sections of code?

What is the difference in execution between the two following sections of code?


A) The loop in the first example will execute one more time than the second example.
B) The first example is an infinite loop.
C) Both loops are executed in an identical manner.
D) The loop in the first example will never be executed.


Correct Answer(s): C