VISUAL BASIC EXAM 2 QUESTIONS
AND ANSWERS 100% PASS
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
d. PrintNewLine - ANS B
, ©THESTAR 2025 ALL RIGHTS RESERVED
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()
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
, ©THESTAR 2025 ALL RIGHTS RESERVED
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
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