Deck 9: Files, Printing, and Structure

ملء الشاشة (f)
exit full mode
سؤال
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
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
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")
سؤال
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()
سؤال
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
سؤال
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
سؤال
When the PrintDocument control's Print method is executed, it triggers the ______event.

A) Printer
B) PrintDoc
C) PagePrint
D) PrintPage
سؤال
This control is used to display a standard Windows Open dialog box.

A) OpenDialog
B) OpenFileDialog
C) OpenWindow
D) OpenWindowDialog
سؤال
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
سؤال
The ___method displays a dialog window when selecting a file that you want to open.

A) DisplayDialogControl
B) DisplayDialog
C) ShowDialog
D) ShowControl
سؤال
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
سؤال
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
سؤال
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 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
سؤال
An application must first ______a file before it can be used.

A) write to
B) read from
C) open
D) unlock
سؤال
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)
سؤال
The method writes data to a file, followed by a newline character immediately after the data.

A) PrintLine
B) WriteLine
C) WriteNewLine
D) Write
سؤال
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
سؤال
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()
سؤال
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
سؤال
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
سؤال
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
سؤال
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
سؤال
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
سؤال
The FontDialog control allows the user to determine the __________.

A) Font
B) Font Style
C) Font Size
D) all of the above
سؤال
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
سؤال
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
سؤال
Reports with columnar data should not use __________.

A) proportionally spaced fonts
B) the Courier New font
C) monospaced fonts
D) all of the above
سؤال
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 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
سؤال
An Open dialog box displays the current folder unless the ______property specifies a different path.

A) InitialFolder
B) DefaultDirectory
C) InitialDirectory
D) DisplayFolder
سؤال
This method places an item of data in a file without terminating the line.

A) WriteLine
B) ReadLine
C) Append
D) Write
سؤال
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
سؤال
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
سؤال
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)
سؤال
The color of text printed by an

A) FontName
B) Style
C) Brushes
D) HPos
E)Graphics.DrawString statement is determined by the __________ argument.
سؤال
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 Deck
1/36
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
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
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
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()
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 36 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 36 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 36 في هذه المجموعة.
فتح الحزمة
k this deck
7
This control is used to display a standard Windows Open dialog box.

A) OpenDialog
B) OpenFileDialog
C) OpenWindow
D) OpenWindowDialog
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 36 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 36 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 36 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 36 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 36 في هذه المجموعة.
فتح الحزمة
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 36 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 36 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 36 في هذه المجموعة.
فتح الحزمة
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)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 36 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 36 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 36 في هذه المجموعة.
فتح الحزمة
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()
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 36 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 36 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 36 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 36 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 36 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 36 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 36 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 36 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 36 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 36 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 36 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 36 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 36 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 36 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 36 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 36 في هذه المجموعة.
فتح الحزمة
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)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 36 في هذه المجموعة.
فتح الحزمة
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 36 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 36 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 36 في هذه المجموعة.