CIS170 Solved Final Exam in VB – Previous Exam – 20 MCQs, 7 Essay Questions – Perfect Solution
Question 1.1. (TCO 1) _____ is/are used to document what a particular piece of code accomplishes. (Points : 5)
Source code
Debugging notes
Output documentation
Comments
Question 2.2. (TCO 2) Which of the following is an ILLEGAL multiple declaration? (Points : 5)
Dim firstName, lastName As String
Dim height as Double, age as Integer
Dim caloriesConsumed as Double numberOfFriesEaten as Integer = 37
Dim gallonsOfGasPurchased as Double = 18.4, gallonsHeldByTank as Integer = 20
Question 3.3. (TCO 3) A variable declared as a(n) _____ holds one character of text. (Points : 5)
Date
Integer
Double
Char
Question 4.4. (TCO 4) What will be the output after the following code executes?
Dim answer As String
Dim number As Integer
number = 8
Select Case number
Case 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
answer = “Less than 10”
Case 10, 11, 12, 13, 14, 15
answer = “Greater than 10”
Case Else
answer = “Greater than 15”
End Select
System.Console.WriteLine(answer) (Points : 5)
Less than 10
Greater than 10
Greater than 15
The program will not compile.
Question 5.5. (TCO 5) A(n) _____ statement can be used to code a loop whose instructions should execute a given number of times. (Points : 5)
If…Then…Else
Select…Case
For…Next
If…ElseIf…Else
Question 6.6. (TCO 6) What is the best way to discover logic errors in a piece of code? (Points : 5)
Compile the program and see if there are errors reported by the compiler.
Compare expected and actual results.
Do a program walk-through with your programming peers.
Include Try…Catch statements in all critical statements.
Question 7.7. (TCO 7) The process of breaking a large program down into manageable pieces is known as top-down design or the _____. (Points : 5)
divide and solve approach
divide and conquer approach
modularity breakdown approach
module division approach
Question 8.8. (TCO 8) We pass arguments by _____ when we pass parameters to a function or sub procedure using the memory address of that parameter. (Points : 5)
parameter
argument
reference
value
Question 9.9. (TCO 9) When implementing a menu in Visual Basic, what programming structure can easily handle the selections made by a user? (Points : 5)
Select … Case statement
Loop statement
Select … Case statement AND Loop statement
None of the above
Question 10.10. (TCO 10) The process in which a programmer presents his or her code to a group of peers for review is called a _____. (Points : 5)
code evaluation
code inspection
code revision
code walk-through
Question 11.11. (TCO 11) We can store a group of variables or _____ in a single array if they are all of the same data type. (Points : 5)
subscripts
subscripted variables
elements
indices
Question 12.12. (TCO 12) Unless the word ReDim is followed by the keyword _____, resizing a Visual Basic array causes the contents to be lost. (Points : 5)
Preserve
Keep
Reserve
Conserve
Question 13.13. (TCO 13) Assume the file MONTHS.TXT contains 12 records, the names of each month in a calendar year. What is stored in RESULTS.TXT after the following code is executed?
Dim monthName As String
Dim sr As IO.StreamReader = IO.File.OpenText(“MONTHS.TXT”)
Do While sr.Peek -1
Dim sw As IO.StreamWriter = IO.File.CreateText(“RESULTS.TXT”)
monthName = sr.ReadLine
sw.WriteLine(monthName)
sw.Close()
Loop
sr.Close() (Points : 5)
January
December
The names of all 12 months
None of the above
Question 14.14. (TCO 3) When the correct arithmetic operator precedence rules are applied, what will be the value of the following expression?
5 * 4 + 10 / 5 (Points : 5)
6
7
22
12
Question 15.15. (TCO 4) Which of the following is true about If…Then…Else structures? (Points : 5)
If…Then…Else structures can be nested.
An If…Then structure is a single selection structure.
If…Then…Else structures are dual selection structures.
All of the above
None of the above
Question 16.16. (TCO 5) How many times will the word “Program” be displayed when the following lines are executed?
Dim counter As Integer = 6
Do
System.Console.WriteLine(“Program”)
counter = counter + 6
Loop Until (counter >= 24) (Points : 5)
Three
Four
Five
None of the above
Question 17.17. (TCO 8) What is displayed when the following code is executed?
Sub Main()
Dim val1, val2 As String
Dim z As Integer = 1
val1 = “Run dog run”
val2 = “dog”
z = Locate(val1, val2)
System.Console.WriteLine(z.ToString())
End Sub
Function Locate(ByVal a As String, ByVal b As String) As Integer
Dim z As Integer
z = a.IndexOf(b)
End Function (Points : 5)
“dog”
0
7
An error
None of the above
Question 18.18. (TCO 5) Consider the following Visual Basic code segments:
Segment 1:
Dim i As Integer = 0
While i <= 1300
Console.WriteLine ( i.ToString("N0") )
i += 1
End While
Segment 2:
For i As Integer = 0 To 1300 Step 1
Console.WriteLine ( i.ToString("N0") )
Next
Which of the following statements is true? (Points : 5)
The output from these segments is the same.
Declaring the counter inside a for loop is illegal.
The output from these segments is not the same.
None of the above
Question 19.19. (TCO 4) Given the case statement below, what would be the value of dblVariable after the code executes?
Dim strVariable As String
strVariable = “F”
Select Case strVariable
Case “A”
dblVariable = 10000
Case “F”
dblVariable = 20000
Case “M”
dblVariable = 30000
Case Else
dblVariable = 40000
End Select (Points : 5)
10000
20000
30000
40000
Question 20.20. (TCO 8) What is wrong with the following call statement and its corresponding sub statement?
Call Statement:
DayOfTheWeek(31, “July”, 1982)
Sub Statement:
Sub DayOfTheWeek(ByVal var1 As Integer, ByVal var2 As String, ByVal var3 As String) (Points : 5)
Constant values like 1982 cannot be passed, only variables.
It is not valid to pass a value like “July.”
var3 is not of the same data type as 1982.
Nothing is wrong with them.
Question 1.1. (TCO 7) Explain what modular code is and provide one advantage of using modular code. (Points : 10)
Question 2.2. (TCO 6) List the three types of errors that can occur in a computer program. Briefly explain how to find and correct each type.
(Points : 10)
Question 3.3. (TCO 5) Assume that counter and exitCondition are Integer variables. Describe precisely the output produced by the following segment for the test inputs 6 and 2.
Dim counter As Integer
Dim exitCondition As Integer = 5
counter = CInt(System.Console.ReadLine())
Do While (counter < exitCondition)
System.Console.WriteLine(counter.ToString("N0"))
counter = counter + 1
Loop
(Points : 10)
Question 4.4. (TCO 5) Write a For Loop that will implement the following logic:
1. Obtain 10 numbers from the user.
2. Compute the average of those numbers.
3. Display the calculated average. (Points : 25)
Question 5.5. (TCO 4) Assume a user will input the total balance of his or her savings account. The user will receive a 2% interest if the balance is at least $500 and 3% interest if the balance is $1,000 or more. Write the VB code to calculate the final balance of the user’s account after interest is applied. (Points : 25)
Question 6.6. (TCO 13) Give a description of the method OpenText(). Make sure to include the following:
1. The purpose of the method (in other words, what it does)
2. An appropriate situation when you would use it in code
3. Sample code showing the syntax of how it is used in Visual Basic programs (Points : 25)
Question 7.7. (TCO 11) ) Consider the following Visual Basic statements:
Dim nums(6) As Double
For index As Integer = 0 To 6
nums(index) = index * 2.5
Next
What values are placed in the array by the above statements? (Show each element of the array, the value for that element, and how you achieve your answer.)
(Points : 25)
* You can also use 2CO option if you want to purchase through Credit Cards/Paypal but make sure you put the correct billing information otherwise you wont be able to receive any download link.
* Your paypal has to be pre-loaded in order to complete the purchase or otherwise please discuss it with us at [email protected].
* As soon as the payment is received, download link of the solution will automatically be sent to the address used in selected payment method.
* Please check your junk mails as the download link email might go there and please be patient for the download link email. Sometimes, due to server congestion, you may receive download link with a delay.
* All the contents are compressed in one zip folder.
* In case if you get stuck at any point during the payment process, please immediately contact us at [email protected] and we will fix it with you.
* We try our best to reach back to you on immediate basis. However, please wait for atleast 8 hours for a response from our side. Afterall, we are humans.
* Comments/Feedbacks are truely welcomed and there might be some incentives for you for the next lab/quiz/assignment.
* In case of any query, please donot hesitate to contact us at [email protected].
* MOST IMPORTANT Please use the tutorials as a guide and they need NOT to be used for any submission. Just take help from the material.
******************************************** Good Luck ***************************************************
Any personal information received will only be used to fill your order. We will not sell or redistribute your information to anyone.
We will try our best to resolve the issue and if still persists we can discuss for a refund in case its required.