Deck 9: Files, Printing, and Structure
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/36
Play
Full screen (f)
Deck 9: Files, Printing, and Structure
1
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
A) a + sign
B) an & symbol
C) a - sign
D) a # symbol
C
2
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.Format(20, 20, "Name", "Address")
D) String.Format(20, 40, "Name", "Address")
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")
A
3
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 = ReadLine(addressFile)
StrCity = ReadLine(addressFile)
Close()
D) Dim addressFile As System.IO.StreamReader addressFile = System.IO.File.OpenText("address.txt")
StrName = addressFile.Input()
StrCity = addressFile.Input()
Close()
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 = ReadLine(addressFile)
StrCity = ReadLine(addressFile)
Close()
D) Dim addressFile As System.IO.StreamReader addressFile = System.IO.File.OpenText("address.txt")
StrName = addressFile.Input()
StrCity = addressFile.Input()
Close()
B
4
Visual Basic allows you to use a(n) statement to eliminate the need to prefix class names with their namespace names.
A) Include
B) With
C) Inherits
D) Imports
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
5
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
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
6
When the PrintDocument control's Print method is executed, it triggers the ______event.
A) Printer
B) PrintDoc
C) PagePrint
D) PrintPage
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
This control is used to display a standard Windows Open dialog box.
A) OpenDialog
B) OpenFileDialog
C) OpenWindow
D) OpenWindowDialog
A) OpenDialog
B) OpenFileDialog
C) OpenWindow
D) OpenWindowDialog
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
8
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) EndOfStream property
B) Poke method
C) EOF flag
D) FileEnd flag
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
9
The ___method displays a dialog window when selecting a file that you want to open.
A) DisplayDialogControl
B) DisplayDialog
C) ShowDialog
D) ShowControl
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
10
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
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
11
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
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
12
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.
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
13
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
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
14
An application must first ______a file before it can be used.
A) write to
B) read from
C) open
D) unlock
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
15
When opening a file, use this method to determine whether a file exists before you attempt to open it:
A) ExistFile(filename)
B) IO.Exists(filename)
C) System.IO.File.Exists(filename)
D) System.File.Exists(filename)
A) ExistFile(filename)
B) IO.Exists(filename)
C) System.IO.File.Exists(filename)
D) System.File.Exists(filename)
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
16
The method writes data to a file, followed by a newline character immediately after the data.
A) PrintLine
B) WriteLine
C) WriteNewLine
D) Write
A) PrintLine
B) WriteLine
C) WriteNewLine
D) Write
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
17
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
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
18
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()
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
19
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
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
20
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
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
21
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
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
22
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
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
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
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
The FontDialog control allows the user to determine the __________.
A) Font
B) Font Style
C) Font Size
D) all of the above
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
25
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
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
26
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
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
27
Reports with columnar data should not use __________.
A) proportionally spaced fonts
B) the Courier New font
C) monospaced fonts
D) all of the above
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
28
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
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
29
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
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
30
An Open dialog box displays the current folder unless the ______property specifies a different path.
A) InitialFolder
B) DefaultDirectory
C) InitialDirectory
D) DisplayFolder
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
31
This method places an item of data in a file without terminating the line.
A) WriteLine
B) ReadLine
C) Append
D) Write
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
32
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.Write(strStudentName(intCount)
OutputFile.Write(", ")
OutputFile.Write(intID(intCount))
OutputFile.Write(", ")
OutputFile.WriteLine(strMajor(intCount))
Next intCount
B) For intCount =0 to strStudentName.Length - 1 outputFile.WriteLine(strStudentName(intCount) & ", ")
OutputFile.WriteLine(intID(intCount) & ", ")
OutputFile.WriteLine(strMajor(intCount))
Next intCount
C) For intCount = 0 to strStudentName.Length - 1 outputFile.Write(strStudentName(intCount))
OutputFile.Write(", ")
OutputFile.Write(intID(intCount))
OutputFile.Write(", ")
OutputFile.Write(strMajor(intCount))
Next intCount
D) For intCount = 1 to strStudentName.Length outputFile.Write(strStudentName(intCount)
OutputFile.Write(", ")
OutputFile.Write(intID(intCount))
OutputFile.Write(", ")
OutputFile.Write(strMajor(intCount))
Next intCount
Nancy Student, 4321, Electrical Engineering
A) For intCount = 0 to strStudentName.Length - 1 outputFile.Write(strStudentName(intCount)
OutputFile.Write(", ")
OutputFile.Write(intID(intCount))
OutputFile.Write(", ")
OutputFile.WriteLine(strMajor(intCount))
Next intCount
B) For intCount =0 to strStudentName.Length - 1 outputFile.WriteLine(strStudentName(intCount) & ", ")
OutputFile.WriteLine(intID(intCount) & ", ")
OutputFile.WriteLine(strMajor(intCount))
Next intCount
C) For intCount = 0 to strStudentName.Length - 1 outputFile.Write(strStudentName(intCount))
OutputFile.Write(", ")
OutputFile.Write(intID(intCount))
OutputFile.Write(", ")
OutputFile.Write(strMajor(intCount))
Next intCount
D) For intCount = 1 to strStudentName.Length outputFile.Write(strStudentName(intCount)
OutputFile.Write(", ")
OutputFile.Write(intID(intCount))
OutputFile.Write(", ")
OutputFile.Write(strMajor(intCount))
Next intCount
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
33
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 Real(Double)
Dim Imaginary(Double)
End Structure
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 Real(Double)
Dim Imaginary(Double)
End Structure
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
34
Which of the following writes a blank line to a text file?
A) outputFile.Write(" ")
B) outputFile.WriteLine.Blank
C) outputFile.WriteLine()
D) outputFile.WriteLine(Blank)
A) outputFile.Write(" ")
B) outputFile.WriteLine.Blank
C) outputFile.WriteLine()
D) outputFile.WriteLine(Blank)
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
35
The color of text printed by an
A) FontName
B) Style
C) Brushes
D) HPos
E)Graphics.DrawString statement is determined by the __________ argument.
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
36
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
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