1. (TCO 1) In order to signify the beginning of a comment statement, we use which of the following character(s)?(Points : 5)
2. (TCO 2) Which of the following statements declares a variable named firstName to be of type String?(Points : 5)
3. (TCO 3) A(n) _____ is a Visual Basic built-in data type.(Points : 5)
4. (TCO 4) Which value(s) could be used to initialize testVariable without creating an error, given the case statement below?
5. (TCO 5) A loop that executes its instructions zero or more times is a(n) _____ loop. (Points : 5)
6. (TCO 6) The _____ button allows execution to enter a procedure and stop on the first line.(Points : 5)
7. (TCO 7) A(n) _____ statement should be the last executable statement of a function.(Points : 5)
8. (TCO 8) What is wrong with the following call statement and its corresponding sub statement?
Call Statement:
GetResults(“Motorcycle”, 8, "Mini Van", 12.3)
Sub Statement:
Call Statement:
GetResults(“Motorcycle”, 8, "Mini Van", 12.3)
Sub Statement:
Sub GetResults (ByVal var1 As String, ByVal var2 As Integer, ByVal var3 As String)(Points : 5)
9. (TCO 9) Which of the following statements specifies that the text displayed in a textBoxOne will be displayed bold? (Points : 5)
10. (TCO 10) Programmers often participate in code walk-throughs in order to improve their codes. What action is NOT taken during a walk-through? (Points : 5)
11. (TCO 11) Which of the following snippets of code will correctly fill an array with the value 4 in each element? The array is declared as follows: (Points : 5)
12. (TCO 12) What is displayed in the console by the following code?
Dim result As Integer
Dim numberArray() As Integer = {1, 2, 3, 4, 5, 6}
ReDim Preserve numberArray (2)
result = numberArray (2)
Dim result As Integer
Dim numberArray() As Integer = {1, 2, 3, 4, 5, 6}
ReDim Preserve numberArray (2)
result = numberArray (2)
System.Console.WriteLine(result) (Points : 5)
13. (TCO 13) In order to write data to a new file, you would _____. (Points : 5)
14. (TCO 3) What value will be assigned to the numeric variable x when the following statement is executed?
x = 2 + 3 * 8 / 2(Points : 5)
15. (TCO 4) What part of the following expression must be false so that the entire expression is evaluated as false?
expression1 And expression2(Points : 5)
16. (TCO 5) What numbers will be displayed by the following code?
Dim x As Double = 9
Do While x > 4
System.Console.WriteLine(x)
x = x - 3
Dim x As Double = 9
Do While x > 4
System.Console.WriteLine(x)
x = x - 3
Loop(Points : 5)
17. (TCO 8) What is displayed when the following code is executed?
Sub Main()
Dim val1 As Integer = 141
Sub Main()
Dim val1 As Integer = 141
Dim val2 As Integer = 251
18. (TCO5) Consider the following Visual Basic code segments:
Segment 1:
Dim i As Integer = 0
While i <=>
Console.WriteLine ( i.ToString("N0") )
i += 1
End While
Segment 2:
For i As Integer = 0 To 20 Step 1
Segment 1:
Dim i As Integer = 0
While i <=>
Console.WriteLine ( i.ToString("N0") )
i += 1
End While
Segment 2:
For i As Integer = 0 To 20 Step 1
Console.WriteLine ( i.ToString("N0") )
19. (TCO 4) What is output by the following Visual Basic code segment?
Dim temp As Integer
temp = 200
If temp > 90 Then
Console.WriteLine("This porridge is too hot.")
ElseIf temp > 50 Then
Console.WriteLine("This porridge is just right!")
Else
Console.WriteLine("This porridge is too cold")
Dim temp As Integer
temp = 200
If temp > 90 Then
Console.WriteLine("This porridge is too hot.")
ElseIf temp > 50 Then
Console.WriteLine("This porridge is just right!")
Else
Console.WriteLine("This porridge is too cold")
End If(Points : 5)
20. (TCO 8) In Visual Basic, arguments are passed by default to user-defined procedures _____. (Points : 5)
1. (TCO 10) What do you think is the most important element in a code walk-through? Why? (Points : 10)
2. (TCO 6) Briefly describe what a runtime error is and how to find/correct it. (Points : 10)
3. (TCO 13) Why is it necessary to "close" a sequential-access file? How do we "close" such a file? (Points : 10)
4. (TCO 6) Write a code segment that will analyze a numeric value provided by the user to determine if he or she is short, average height, or tall. Make sure to include the following in your code:
· Display the message "Please enter your height in feet.” to the user.
· Use the ReadLine() method to obtain a value from the user.
· Use the Parse() method to convert the user’s value to an appropriate data type for numeric comparisons.
· Check to be sure the user entered a value greater than or equal to 0.0 and less than or equal to 8.0.
· Display the message "Please enter your height in feet.” to the user.
· Use the ReadLine() method to obtain a value from the user.
· Use the Parse() method to convert the user’s value to an appropriate data type for numeric comparisons.
· Check to be sure the user entered a value greater than or equal to 0.0 and less than or equal to 8.0.
· Use ElseIf statements to determine whether a user is short, average or tall. An input value of 0 up to but not including 5.0 feet is considered short. An input value of 5.0 up to but not including 6.0 feet is considered average height. Any height greater than or equal to 6.0 is considered tall. (Points : 25)
5. (TCO 5) Write a For loop that will display all numbers that are multiples of 10 from 0 to 100 and then display the average of the displayed numbers. (Points : 25)
6. (TCO 5) Visual Basic provides several types of loops. Answer the following questions with respect to Do loops and Do While loops:
- Explain the difference between a Do loop and a Do While loop.
- Explain the difference between a Do loop and a Do While loop.
In Do loop the condition is checked after the loop statements while in Do While loop the condition is checked at the start of the loop.
- When would you use one vs. the other?
I would use the Do loop when I need my statements to execute for at least once and I would use Do while loop when I need loop statements to be executed only after checking the condition
- Provide an example of a Do loop.
7. (TCO 12) Describe one programming situation where you would dynamically change the length of an array
Комментариев нет:
Отправить комментарий