VISUAL BASIC EXAM 2 QUESTIONS & ANSWERS
GRADED A+/NEWEST UPDATE Questions and
Correct Answers/ Latest Update / Already Graded
To retain data between different times that the program runs, an application
must have
a way of the data in a file.
a. Adding
b. Encrypting
c. Saving
d. Deleting
Ans: c.Saving
A file is like a stream of data that must be read from its beginning to its end.
a. direct access
b. binary format
c. sequential access
d. direct format
Ans: c.sequential access
The method is used to write data to a file and then writes a newline character
immediately after the data.
a. PrintLine
b. WriteLine
c. WriteNewLine
© 2025/ 2026 | ® All rights reserved
, 2 | Page
d. PrintNewLine
Ans: B
4. Assume the file address.txt contains the following lines:
Bob Johnson
Somewhere USA
Which of the following code segments will read the data from the file and put the
data
into two variables named strName, and strCity.
a. Dim addressFile As System.IO.StreamReader
addressFile = addressFile.OpenText("address.txt")
strName = addressFile.ReadLine()
strCity = addressFile.ReadLine()
addressFile.Close()
CS2453 - Exam 3 Review Page 2 of 14
b. Dim addressFile As System.IO.StreamReader
addressFile = System.IO.File.OpenText("address.txt")
strName = addressFile.ReadLine()
strCity = addressFile.ReadLine()
addressFile.Close()
c. Dim addressFile As System.IO.StreamReader
addressFile = OpenText("address.txt")
strName = addressFile.ReadLine()
© 2025/ 2026 | ® All rights reserved
, 3 | Page
strCity = addressFile.ReadLine()
Close()
d. Dim addressFile As System.IO.StreamReader
addressFile = System.IO.File.OpenText("address.txt")
strName = addressFile.Input ()
strCity = addressFile.
Ans: B
5. When opening a file you should use this method to determine whether a file
exists
before you attempt to open it
a. File.Exists
b. IO.Exists
c. System.IO.Exists
d. System.File.Exists
Ans: A
6. This control can display a standard Windows Open dialog box.
a. OpenDialog
b. OpenFileDialog
c. OpenWindow
d. OpenWindowDialog
Ans: B
© 2025/ 2026 | ® All rights reserved
, 4 | Page
7. Which of the following statements does the following?
Formats a line of text to have the word "Name" in the first column, which is 20
characters wide, and have the word "Address" in the second column, which is
also 20 characters wide.
a. String.Format("{0, 20}{1, 20}", "Name", "Address")
b. String.Format("{ 20}{ 20}", "Name", "Address")
c. String.Format(20, 20, "Name", "Address")
d. String.Format(20, 40, "Name", "Address")
CS2453 - Exam 3 Review Page 3 of 14
Ans: A
8. To left justify the columns in the String.Format method you would use
preceding the numbers for the column width.
a. a + sign
b. an & symbol
c. a - sign
d. a # symbol
Ans: C
9. All of the following steps must be taken when a file is used by an application
except
a. The file must be opened. If the file does not exist, opening it means
creating it.
© 2025/ 2026 | ® All rights reserved