Deck 9: Files, Printing, and Structures

Full screen (f)
exit full mode
Question
This control is used to display a standard Windows Open dialog box.

A) OpenDialog
B) OpenFileDialog
C) OpenWindow
D) OpenWindowDialog
Use Space or
up arrow
down arrow
to flip the card.
Question
The method writes data to a file, followed by a newline character immediately after the data.

A) PrintLine
B) WriteLine
C) WriteNewLine
D) Write
Question
The StreamReader object's _is used to determine when the end of the file has been reached.

A) EndOfStream property
B) Poke method
C) EOF flag
D) FileEnd flag
Question
In order to retain data while a program is not running, data must be saved in .

A) RAM
B) a ListBox
C) a control
D) a file
Question
When opening a file, use this method to determine whether a file exists before you attempt to open it:

A) ExistFilefilename)
B) IO.Existsfilename)
C) System.IO.File.Existsfilename)
D) System.File.Existsfilename)
Question
When the PrintDocument control's Print method is executed, it triggers the _event.

A) Printer
B) PrintDoc
C) PagePrint
D) PrintPage
Question
Visual Basic allows you to use an) statement to eliminate the need to prefix class names with their namespace names.

A) Include
B) With
C) Inherits
D) Imports
Question
When a file is selected from an Open dialog box, the path and file name are stored in the control's _property?

A) Filename
B) PathName
C) File
D) Item
Question
The StreamWriter's CreateText method will ___.

A) create a new file or replace an existing one
B) append text at the end of the existing file
C) insert text at the beginning of the file
D) maintain the data for an existing file
Question
To left justify the columns in the String.Format method, use preceding the column width.

A) a + sign
B) an & symbol
C) a - sign
D) a # symbol
Question
The dialog controls which open or save files are displayed using the _method.

A) DisplayDialogControl
B) DisplayDialog
C) ShowDialog
D) ShowControl
Question
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
Question
The StreamReader.Read method will ___.

A) read the file until an end of line character is reached.
B) read the next character from a file
C) read the contents of the file from the current read position to end of file
D) read the next word from a file
Question
___ 14. 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, the file will be created.
B) the file must have a fully qualified path when opening the file.
C) data is either written to the file or read from the file.
D) when the application is finished using the file, the file is closed.
Question
The following statements describe advantages of the Open and Save As dialog boxes except .

A) they help make an application more consistent with other Windows applications
B) they give users the ability to browse for a file
C) these dialog boxes show the user how to create and use files
D) they allow a file to be specified without typing a long path and filename
Question
An application must first _a file before it can be used.

A) write to
B) read from
C) open
D) unlock
Question
Which of the following code segments creates a new file named address.txt, writes the following two lines to the file, and then closes the file? Bob Johnson
Somewhere USA

A) Dim addressFile As System.IO.StreamWriter addressFile = System.IO.File.CreateText"address.txt")
AddressFile.Write"Bob Johnson")
AddressFile.Write"Somewhere USA")
Address.txt.Close)
B) Dim addressFile As System.IO addressFile = System.IO.File.CreateText"address.txt")
AddressFile.WriteLine"Bob Johnson")
AddressFile.WriteLine"Somewhere USA")
AddressFile.Close)
C) Dim addressFile As System.IO.StreamWriter addressFile = System.IO.File.CreateText"address.txt")
AddressFile.WriteLine"Bob Johnson")
AddressFile.WriteLine"Somewhere USA")
AddressFile.Close)
D) Dim addressFile As StreamWriter addressFile = System.IO.File.CreateText"address.txt")
AddressFile.PrintLine"Bob Johnson")
AddressFile.PrintLine"Somewhere USA")
Close)
Question
Which of the following code segments will read the following two lines from addressFile and place the data in two variables named strName, and strCity? Bob Johnson
Somewhere USA

A) Dim addressFile As System.IO.StreamReader addressFile = System.OpenText"address.txt")
StrName = addressFile.ReadLine)
StrCity = addressFile.ReadLine)
AddressFile.Close)
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 = ReadLineaddressFile)
StrCity = ReadLineaddressFile)
Close)
D) Dim addressFile As System.IO.StreamReader addressFile = System.IO.File.OpenText"address.txt")
StrName = addressFile.Input)
StrCity = addressFile.Input)
Close)
Question
Identify the following statements which will: Format a string to contain the word "Name" in a column of 20 characters wide, followed by the word "Address" in a second column, also 20 characters wide.

A) String.Format"{0, 20}{1, 20}", "Name", "Address")
B) String.Format"{ 20}{ 20}", "Name", "Address")
C) String.Format20, 20, "Name", "Address")
D) String.Format20, 40, "Name", "Address")
Question
Which of the following statements are not true about text files?

A) contains plain text
B) cannot be viewed with an editor such as Notepad
C) is the simplest type of data file
D) known as a sequential-access file
Question
An Open dialog box displays the current folder unless the _property specifies a different path.

A) InitialFolder
B) DefaultDirectory
C) InitialDirectory
D) DisplayFolder
Question
Which of the following declares a structure data type named Complex, which has two fields named Real and Imaginary, both of which are of type Double?

A) Declare Structure Complex Dim Real As Double
Dim Imaginary As Double
End Declare
B) Structure Complex Dim Real as Double
Dim Imaginary as Double
End Structure
C) Structure As Complex Dim Real As Double
Dim Imaginary As Double
End Structure
D) Dim Structure Complex Dim RealDouble)
Dim ImaginaryDouble)
End Structure
Question
This method is used to add more data to the end of an existing file.

A) System.IO.File.OpenText
B) System.IO.File.AppendText
C) System.IO.File.CreateText
D) System.IO.File.OpenNew
Question
Reports with columnar data should not use .

A) proportionally spaced fonts
B) the Courier New font
C) monospaced fonts
D) all of the above
Question
This predefined constant moves the print position forward to the next even multiple of 8 columns.

A) ControlChars.CrLf
B) Tab
C) vbTab
D) Space
Question
The fields within a structure can be .

A) String data types
B) Integer data types
C) an array of Double data types
D) all of the above
Question
This method places an item of data in a file without terminating the line.

A) WriteLine
B) ReadLine
C) Append
D) Write
Question
To change the color of text in a windows form, you could use this.

A) FontDialog control
B) ColorDialog control
C) FontDialog control with the ShowColor property set to True
D) both b and c are correct
Question
What does the following line do? Do Until inputFile.EndOfStream

A) Checks to see if the file exists
B) Checks to see if the next input is -1
C) Checks to see if the file is empty
D) Checks to see if all the data in the file has been read
Question
The FontDialog control allows the user to determine the .

A) Font
B) Font Style
C) Font Size
D) all of the above
Question
The color of text printed by an

A) FontName
B) Style
C) Brushes
D) HPos
E)Graphics.DrawString statement is determined by the __________ argument.
Question
Which of the following writes a blank line to a text file?

A) outputFile.Write" ")
B) outputFile.WriteLine.Blank
C) outputFile.WriteLine)
D) outputFile.WriteLineBlank)
Question
Which of the following code segments writes the contents of three parallel arrays named strStudentName, intID, and strMajor to a file in the format below? Assume all arrays have the same number of elements. Vince Student, 1234, Computer Science
Nancy Student, 4321, Electrical Engineering

A) For intCount = 0 to strStudentName.Length - 1 outputFile.WritestrStudentNameintCount)
OutputFile.Write", ")
OutputFile.WriteintIDintCount))
OutputFile.Write", ")
OutputFile.WriteLinestrMajorintCount))
Next intCount
B) For intCount =0 to strStudentName.Length - 1 outputFile.WriteLinestrStudentNameintCount) & ", ")
OutputFile.WriteLineintIDintCount) & ", ")
OutputFile.WriteLinestrMajorintCount))
Next intCount
C) For intCount = 0 to strStudentName.Length - 1 outputFile.WritestrStudentNameintCount))
OutputFile.Write", ")
OutputFile.WriteintIDintCount))
OutputFile.Write", ")
OutputFile.WritestrMajorintCount))
Next intCount
D) For intCount = 1 to strStudentName.Length outputFile.WritestrStudentNameintCount)
OutputFile.Write", ")
OutputFile.WriteintIDintCount))
OutputFile.Write", ")
OutputFile.WritestrMajorintCount))
Next intCount
Question
This property allows the developer to specify the type of files that will appear in a dialog box.

A) InitialFile property
B) FileFilter property
C) Files property
D) Filter property
Question
To serve as a visual reminder that the structure or class name is not a variable, structure names and class names should _.

A) Begin with uppercase letters
B) Begin with an underscore
C) End with a letter
D) all of the above
Question
A structure should be used instead of an array when .

A) related items should be grouped together
B) related items are of different data types
C) related items contain strings of different lengths
D) there are a limited number of related items
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/36
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 9: Files, Printing, and Structures
1
This control is used to display a standard Windows Open dialog box.

A) OpenDialog
B) OpenFileDialog
C) OpenWindow
D) OpenWindowDialog
B
2
The method writes data to a file, followed by a newline character immediately after the data.

A) PrintLine
B) WriteLine
C) WriteNewLine
D) Write
B
3
The StreamReader object's _is used to determine when the end of the file has been reached.

A) EndOfStream property
B) Poke method
C) EOF flag
D) FileEnd flag
A
4
In order to retain data while a program is not running, data must be saved in .

A) RAM
B) a ListBox
C) a control
D) a file
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
5
When opening a file, use this method to determine whether a file exists before you attempt to open it:

A) ExistFilefilename)
B) IO.Existsfilename)
C) System.IO.File.Existsfilename)
D) System.File.Existsfilename)
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
6
When the PrintDocument control's Print method is executed, it triggers the _event.

A) Printer
B) PrintDoc
C) PagePrint
D) PrintPage
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
7
Visual Basic allows you to use an) statement to eliminate the need to prefix class names with their namespace names.

A) Include
B) With
C) Inherits
D) Imports
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
8
When a file is selected from an Open dialog box, the path and file name are stored in the control's _property?

A) Filename
B) PathName
C) File
D) Item
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
9
The StreamWriter's CreateText method will ___.

A) create a new file or replace an existing one
B) append text at the end of the existing file
C) insert text at the beginning of the file
D) maintain the data for an existing file
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
10
To left justify the columns in the String.Format method, use preceding the column width.

A) a + sign
B) an & symbol
C) a - sign
D) a # symbol
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
11
The dialog controls which open or save files are displayed using the _method.

A) DisplayDialogControl
B) DisplayDialog
C) ShowDialog
D) ShowControl
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
12
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
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
13
The StreamReader.Read method will ___.

A) read the file until an end of line character is reached.
B) read the next character from a file
C) read the contents of the file from the current read position to end of file
D) read the next word from a file
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
14
___ 14. 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, the file will be created.
B) the file must have a fully qualified path when opening the file.
C) data is either written to the file or read from the file.
D) when the application is finished using the file, the file is closed.
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
15
The following statements describe advantages of the Open and Save As dialog boxes except .

A) they help make an application more consistent with other Windows applications
B) they give users the ability to browse for a file
C) these dialog boxes show the user how to create and use files
D) they allow a file to be specified without typing a long path and filename
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
16
An application must first _a file before it can be used.

A) write to
B) read from
C) open
D) unlock
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
17
Which of the following code segments creates a new file named address.txt, writes the following two lines to the file, and then closes the file? Bob Johnson
Somewhere USA

A) Dim addressFile As System.IO.StreamWriter addressFile = System.IO.File.CreateText"address.txt")
AddressFile.Write"Bob Johnson")
AddressFile.Write"Somewhere USA")
Address.txt.Close)
B) Dim addressFile As System.IO addressFile = System.IO.File.CreateText"address.txt")
AddressFile.WriteLine"Bob Johnson")
AddressFile.WriteLine"Somewhere USA")
AddressFile.Close)
C) Dim addressFile As System.IO.StreamWriter addressFile = System.IO.File.CreateText"address.txt")
AddressFile.WriteLine"Bob Johnson")
AddressFile.WriteLine"Somewhere USA")
AddressFile.Close)
D) Dim addressFile As StreamWriter addressFile = System.IO.File.CreateText"address.txt")
AddressFile.PrintLine"Bob Johnson")
AddressFile.PrintLine"Somewhere USA")
Close)
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
18
Which of the following code segments will read the following two lines from addressFile and place the data in two variables named strName, and strCity? Bob Johnson
Somewhere USA

A) Dim addressFile As System.IO.StreamReader addressFile = System.OpenText"address.txt")
StrName = addressFile.ReadLine)
StrCity = addressFile.ReadLine)
AddressFile.Close)
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 = ReadLineaddressFile)
StrCity = ReadLineaddressFile)
Close)
D) Dim addressFile As System.IO.StreamReader addressFile = System.IO.File.OpenText"address.txt")
StrName = addressFile.Input)
StrCity = addressFile.Input)
Close)
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
19
Identify the following statements which will: Format a string to contain the word "Name" in a column of 20 characters wide, followed by the word "Address" in a second column, also 20 characters wide.

A) String.Format"{0, 20}{1, 20}", "Name", "Address")
B) String.Format"{ 20}{ 20}", "Name", "Address")
C) String.Format20, 20, "Name", "Address")
D) String.Format20, 40, "Name", "Address")
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
20
Which of the following statements are not true about text files?

A) contains plain text
B) cannot be viewed with an editor such as Notepad
C) is the simplest type of data file
D) known as a sequential-access file
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
21
An Open dialog box displays the current folder unless the _property specifies a different path.

A) InitialFolder
B) DefaultDirectory
C) InitialDirectory
D) DisplayFolder
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
22
Which of the following declares a structure data type named Complex, which has two fields named Real and Imaginary, both of which are of type Double?

A) Declare Structure Complex Dim Real As Double
Dim Imaginary As Double
End Declare
B) Structure Complex Dim Real as Double
Dim Imaginary as Double
End Structure
C) Structure As Complex Dim Real As Double
Dim Imaginary As Double
End Structure
D) Dim Structure Complex Dim RealDouble)
Dim ImaginaryDouble)
End Structure
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
23
This method is used to add more data to the end of an existing file.

A) System.IO.File.OpenText
B) System.IO.File.AppendText
C) System.IO.File.CreateText
D) System.IO.File.OpenNew
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
24
Reports with columnar data should not use .

A) proportionally spaced fonts
B) the Courier New font
C) monospaced fonts
D) all of the above
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
25
This predefined constant moves the print position forward to the next even multiple of 8 columns.

A) ControlChars.CrLf
B) Tab
C) vbTab
D) Space
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
26
The fields within a structure can be .

A) String data types
B) Integer data types
C) an array of Double data types
D) all of the above
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
27
This method places an item of data in a file without terminating the line.

A) WriteLine
B) ReadLine
C) Append
D) Write
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
28
To change the color of text in a windows form, you could use this.

A) FontDialog control
B) ColorDialog control
C) FontDialog control with the ShowColor property set to True
D) both b and c are correct
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
29
What does the following line do? Do Until inputFile.EndOfStream

A) Checks to see if the file exists
B) Checks to see if the next input is -1
C) Checks to see if the file is empty
D) Checks to see if all the data in the file has been read
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
30
The FontDialog control allows the user to determine the .

A) Font
B) Font Style
C) Font Size
D) all of the above
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
31
The color of text printed by an

A) FontName
B) Style
C) Brushes
D) HPos
E)Graphics.DrawString statement is determined by the __________ argument.
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
32
Which of the following writes a blank line to a text file?

A) outputFile.Write" ")
B) outputFile.WriteLine.Blank
C) outputFile.WriteLine)
D) outputFile.WriteLineBlank)
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
33
Which of the following code segments writes the contents of three parallel arrays named strStudentName, intID, and strMajor to a file in the format below? Assume all arrays have the same number of elements. Vince Student, 1234, Computer Science
Nancy Student, 4321, Electrical Engineering

A) For intCount = 0 to strStudentName.Length - 1 outputFile.WritestrStudentNameintCount)
OutputFile.Write", ")
OutputFile.WriteintIDintCount))
OutputFile.Write", ")
OutputFile.WriteLinestrMajorintCount))
Next intCount
B) For intCount =0 to strStudentName.Length - 1 outputFile.WriteLinestrStudentNameintCount) & ", ")
OutputFile.WriteLineintIDintCount) & ", ")
OutputFile.WriteLinestrMajorintCount))
Next intCount
C) For intCount = 0 to strStudentName.Length - 1 outputFile.WritestrStudentNameintCount))
OutputFile.Write", ")
OutputFile.WriteintIDintCount))
OutputFile.Write", ")
OutputFile.WritestrMajorintCount))
Next intCount
D) For intCount = 1 to strStudentName.Length outputFile.WritestrStudentNameintCount)
OutputFile.Write", ")
OutputFile.WriteintIDintCount))
OutputFile.Write", ")
OutputFile.WritestrMajorintCount))
Next intCount
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
34
This property allows the developer to specify the type of files that will appear in a dialog box.

A) InitialFile property
B) FileFilter property
C) Files property
D) Filter property
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
35
To serve as a visual reminder that the structure or class name is not a variable, structure names and class names should _.

A) Begin with uppercase letters
B) Begin with an underscore
C) End with a letter
D) all of the above
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
36
A structure should be used instead of an array when .

A) related items should be grouped together
B) related items are of different data types
C) related items contain strings of different lengths
D) there are a limited number of related items
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 36 flashcards in this deck.