Deck 15: Files, Streams and Object Serialization
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/26
العب
ملء الشاشة (f)
Deck 15: Files, Streams and Object Serialization
1
Adding the services of one stream to another is known as ________.
A) chaining
B) wrapping
C) adding
D) sequencing
A) chaining
B) wrapping
C) adding
D) sequencing
B
2
What interface must a class implement to indicate that objects of the class can be output and input as a stream of bytes?
A) Synchronize
B) Deserializable
C) Serializable
D) ObjectOutput
A) Synchronize
B) Deserializable
C) Serializable
D) ObjectOutput
C
3
What does the following statement do?
Scanner scanner = new Scanner(Paths.get("test.txt"));
A) Opens a binary file for input.
B) Opens a binary file for output.
C) Opens a text file for input.
D) Opens a text file for output.
Scanner scanner = new Scanner(Paths.get("test.txt"));
A) Opens a binary file for input.
B) Opens a binary file for output.
C) Opens a text file for input.
D) Opens a text file for output.
C
4
Path method ________ returns the String name of a file or directory without any location information.
A) getStringName
B) getFileOrDirectoryName
C) getDirectoryName
D) getFileName
A) getStringName
B) getFileOrDirectoryName
C) getDirectoryName
D) getFileName
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 26 في هذه المجموعة.
فتح الحزمة
k this deck
5
Which of the following statements is true?
A) Class Scanner provides the ability to reposition to the beginning of a file with method seek.
B) Class Scanner provides the ability to reposition to the beginning of a file with method reposition.
C) Class Scanner does not provide the ability to reposition to the beginning of the file.
D) If it is necessary to read a sequential file again, the program can simply keep reading-when the end of the file is reached, the Scanner is automatically set to point back to the beginning of the file.
A) Class Scanner provides the ability to reposition to the beginning of a file with method seek.
B) Class Scanner provides the ability to reposition to the beginning of a file with method reposition.
C) Class Scanner does not provide the ability to reposition to the beginning of the file.
D) If it is necessary to read a sequential file again, the program can simply keep reading-when the end of the file is reached, the Scanner is automatically set to point back to the beginning of the file.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 26 في هذه المجموعة.
فتح الحزمة
k this deck
6
Instance variables that are not to be output with a Serializable object are declared using which keyword?
A) private
B) ignoreme
C) transient
D) persistent
A) private
B) ignoreme
C) transient
D) persistent
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 26 في هذه المجموعة.
فتح الحزمة
k this deck
7
________ path starts from the directory in which the application began executing.
A) absolute
B) relative
C) parallel
D) comparative
A) absolute
B) relative
C) parallel
D) comparative
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 26 في هذه المجموعة.
فتح الحزمة
k this deck
8
Which of the following statements is false?
A) A Path represents the location of a file or directory.
B) Path objects open files and provide file-processing capabilities.
C) Class Paths is used to get a Path object representing a file or directory location.
D) The static method get of class Paths converts a String representing a file's or directory's location into a Path object.
A) A Path represents the location of a file or directory.
B) Path objects open files and provide file-processing capabilities.
C) Class Paths is used to get a Path object representing a file or directory location.
D) The static method get of class Paths converts a String representing a file's or directory's location into a Path object.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 26 في هذه المجموعة.
فتح الحزمة
k this deck
9
Streams that input bytes from and output bytes to files are known as ________.
A) bit-based streams
B) byte-based streams
C) character-based streams
D) Unicode-based streams
A) bit-based streams
B) byte-based streams
C) character-based streams
D) Unicode-based streams
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 26 في هذه المجموعة.
فتح الحزمة
k this deck
10
A serialized object is ________.
A) an object represented as a sequence of bytes used to store the object's data in a file
B) an object in memory that has been recreated from data in a file
C) a standard output stream object used to convert objects in code to data in a file
D) None of the above.
A) an object represented as a sequence of bytes used to store the object's data in a file
B) an object in memory that has been recreated from data in a file
C) a standard output stream object used to convert objects in code to data in a file
D) None of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 26 في هذه المجموعة.
فتح الحزمة
k this deck
11
Which of the following statements is false?
A) A DirectoryStream enables a program to iterate through the contents of a directory.
B) Character-based input and output can be performed with classes Scanner and Formatter.
C) A relative path contains all the directories, starting with the root directory, that lead to a specific file or directory.
D) Every file or directory on a disk drive has the same root directory in its path.
A) A DirectoryStream enables a program to iterate through the contents of a directory.
B) Character-based input and output can be performed with classes Scanner and Formatter.
C) A relative path contains all the directories, starting with the root directory, that lead to a specific file or directory.
D) Every file or directory on a disk drive has the same root directory in its path.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 26 في هذه المجموعة.
فتح الحزمة
k this deck
12
Which statement regarding Java files is false?
A) Java imposes no structure on a file.
B) Notions like "record" do not exist in Java files.
C) The programmer must structure files to meet the requirements of applications.
D) Records in a Java sequential file are stored in order by record key.
A) Java imposes no structure on a file.
B) Notions like "record" do not exist in Java files.
C) The programmer must structure files to meet the requirements of applications.
D) Records in a Java sequential file are stored in order by record key.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 26 في هذه المجموعة.
فتح الحزمة
k this deck
13
Which of the following statements is false?
A) Storage of data variables and arrays is temporary.
B) Data is lost when a local variable "goes out of scope."
C) Files are used for long-term retention of large amounts of data.
D) Data maintained in files is often called transient data.
A) Storage of data variables and arrays is temporary.
B) Data is lost when a local variable "goes out of scope."
C) Files are used for long-term retention of large amounts of data.
D) Data maintained in files is often called transient data.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 26 في هذه المجموعة.
فتح الحزمة
k this deck
14
Records in a sequential file are not usually updated in place. Instead ________.
A) the updated data is placed in a "surrogate" file
B) the entire file is usually rewritten
C) the file is truncated
D) The above statement is false-records in sequential files are usually updated in place.
A) the updated data is placed in a "surrogate" file
B) the entire file is usually rewritten
C) the file is truncated
D) The above statement is false-records in sequential files are usually updated in place.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 26 في هذه المجموعة.
فتح الحزمة
k this deck
15
How do methods setIn, setOut and setErr affect the standard input, output and error streams?
A) They output data to the standard input, output and error streams.
B) They provide the only way to access the standard input, output and error streams.
C) They redirect the standard input, output and error streams.
D) They empty the standard input, output and error streams.
A) They output data to the standard input, output and error streams.
B) They provide the only way to access the standard input, output and error streams.
C) They redirect the standard input, output and error streams.
D) They empty the standard input, output and error streams.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 26 في هذه المجموعة.
فتح الحزمة
k this deck
16
When all the contents of a file are truncated, this means that ________.
A) the data in the file is saved to a backup file
B) the file is deleted
C) a FileNotFoundException occurs
D) all the data in the file is discarded
A) the data in the file is saved to a backup file
B) the file is deleted
C) a FileNotFoundException occurs
D) all the data in the file is discarded
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 26 في هذه المجموعة.
فتح الحزمة
k this deck
17
Class ________ provides static methods for common file and directory manipulations, including methods for copying files; creating and deleting files and directories; getting information about files and directories; reading the contents of files; getting objects that allow you to manipulate the contents of files and directories; and more.
A) File
B) FileAndDirectory
C) Files
D) FilesAndDirectories
A) File
B) FileAndDirectory
C) Files
D) FilesAndDirectories
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 26 في هذه المجموعة.
فتح الحزمة
k this deck
18
Which of the following classes is not used for file input?
A) FileInputStream
B) FileReader
C) ObjectInputStream
D) Formatter
A) FileInputStream
B) FileReader
C) ObjectInputStream
D) Formatter
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 26 في هذه المجموعة.
فتح الحزمة
k this deck
19
Which of the following classes enable input and output of entire objects to or from a file?
A) SerializedInputStream
B) SerializedOutputStream
C) ObjectInputStream
D) ObjectOutputStream
E) Scanner
F) Formatter
A) A and B.
B) C and D.
C) C, D, E, F.
D) E and F.
A) SerializedInputStream
B) SerializedOutputStream
C) ObjectInputStream
D) ObjectOutputStream
E) Scanner
F) Formatter
A) A and B.
B) C and D.
C) C, D, E, F.
D) E and F.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 26 في هذه المجموعة.
فتح الحزمة
k this deck
20
Files static method ________ receives a Path and returns a boolean indicating whether that Path represents a directory on disk.
A) isDiskDirectory
B) isDirectory
C) isFileDirectory
D) isPath
A) isDiskDirectory
B) isDirectory
C) isFileDirectory
D) isPath
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 26 في هذه المجموعة.
فتح الحزمة
k this deck
21
________ is an I/O-performance-enhancement technique-it reduces the number of I/O operations by combining smaller outputs together in memory; the number of physical I/O operations is much smaller than the number of I/O requests issued by the program.
A) Aggregating
B) Accumulating
C) Amassing
D) Buffering
A) Aggregating
B) Accumulating
C) Amassing
D) Buffering
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 26 في هذه المجموعة.
فتح الحزمة
k this deck
22
Which JFileChooser method returns the file the user selected?
A) getSelectedFile.
B) getFile.
C) getOpenDialog.
D) showOpenDialog.
A) getSelectedFile.
B) getFile.
C) getOpenDialog.
D) showOpenDialog.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 26 في هذه المجموعة.
فتح الحزمة
k this deck
23
Which of the following statements is false?
A) With a BufferedOutputStream each output operation is directed to a buffer large enough to hold the data of many output operations. Transfer to the output device is performed in one large physical output operation when the buffer fills.
B) With a BufferedOutputStream, a partially filled buffer can be forced out to the device at any time by invoking the stream object's force method.
C) With a BufferedInputStream, many "logical" chunks of data from a file are read as one large physical input operation into a memory buffer.
D) With a BufferedInputStream, as a program requests data, it's taken from the buffer. When the buffer is empty, the next actual physical input operation is performed.
A) With a BufferedOutputStream each output operation is directed to a buffer large enough to hold the data of many output operations. Transfer to the output device is performed in one large physical output operation when the buffer fills.
B) With a BufferedOutputStream, a partially filled buffer can be forced out to the device at any time by invoking the stream object's force method.
C) With a BufferedInputStream, many "logical" chunks of data from a file are read as one large physical input operation into a memory buffer.
D) With a BufferedInputStream, as a program requests data, it's taken from the buffer. When the buffer is empty, the next actual physical input operation is performed.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 26 في هذه المجموعة.
فتح الحزمة
k this deck
24
The ________ abstract classes are Unicode character-based streams.
A) Reader and Writer
B) BufferedReader and BufferedWriter
C) CharArrayReader and CharArrayWriter
D) UnicodeReader and UnicodeWriter
A) Reader and Writer
B) BufferedReader and BufferedWriter
C) CharArrayReader and CharArrayWriter
D) UnicodeReader and UnicodeWriter
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 26 في هذه المجموعة.
فتح الحزمة
k this deck
25
Which JFileChooser method specifies what users can select in the dialog?
A) setFileSelectionMode
B) setSelectionMode
C) showOpenDialog
D) None of the above.
A) setFileSelectionMode
B) setSelectionMode
C) showOpenDialog
D) None of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 26 في هذه المجموعة.
فتح الحزمة
k this deck
26
When using an ObjectInputStream to read data from a file, what happens when an end-of-file marker is reached?
A) Nothing occurs.
B) An end-of-file character is read by the program.
C) Method readObject returns the value 0.
D) An EOFException is thrown.
A) Nothing occurs.
B) An end-of-file character is read by the program.
C) Method readObject returns the value 0.
D) An EOFException is thrown.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 26 في هذه المجموعة.
فتح الحزمة
k this deck