Deck 15: Files, Inputoutput Streams, Nio and Xml Serialization

ملء الشاشة (f)
exit full mode
سؤال
Which of the following is false?

A) JAXB (Java Architecture for XML Binding) enables you to perform XML serialization.
B) Marshaling is the process of deserializing an object.
C) A serialized object is represented by XML that includes the object's data.
D) XML (eXtensible Markup Language) is a widely used language for describing data.
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
Which of the following statements is false?

A) Path method isAbsolute returns a boolean indicating whether a Path represents an absolute path to a file or directory.
B) Files static method getLastModifiedTime receives a Path and returns a FileTime (package java.nio.file.attribute) indicating when the file was last modified.
C) Files static method size receives a Path and returns a long representing the number of bytes in the file or directory. For directories, the value returned is platform specific.
D) All of the above are true.
سؤال
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
سؤال
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.
سؤال
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.
سؤال
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.
سؤال
Which of the following is false?

A) JAXB works with POJOs (plain old Java objects)-no special superclasses or interfaces are required for XML-serialization support.
B) JAXB serializes only an object's public instance variables and public read-write properties.
C) A class must provide a public default or no-argument constructor to recreate the objects when they're read from the file.
D) JAXB requires you to implement special superclasses and interfaces for XML-serialization support.
سؤال
Path method ________ returns the String name of a file or directory without any location information.

A) getStringName
B) getFileOrDirectoryName
C) getDirectoryName
D) getFileName
سؤال
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.
سؤال
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
سؤال
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(n) ________ path starts from the directory in which the application began executing.

A) absolute
B) relative
C) parallel
D) comparative
سؤال
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
سؤال
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.
سؤال
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.
سؤال
A serialized object is ________.

A) an object represented by XML that includes the object's data.
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.
سؤال
The annotation ________ indicates that a private instance variable should be serialized.

A) @XMLElement
B) @Element
C) @Marshal
D) @Serialize
سؤال
Which of the following classes is not used for file input?

A) FileInputStream
B) FileReader
C) ObjectInputStream
D) Formatter
سؤال
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.
سؤال
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
سؤال
JavaFX classes ________ and ________ (package javafx.stage) display dialogs that enable the user to select a file or directory, respectively.

A) Files, Directories
B) FileChooser, DirectoryChooser
C) FileSelector, DirectorySelector
D) None of the above.
سؤال
The ________ abstract classes are Unicode character-based streams.

A) Reader and Writer
B) BufferedReader and BufferedWriter
C) CharArrayReader and CharArrayWriter
D) UnicodeReader and UnicodeWriter
سؤال
Which of the following statements is false?

A) InputStream and OutputStream are abstract classes for performing byte-based I/O.
B) Tubes are synchronized communication channels between threads.
C) A filter stream provides additional functionality, such as aggregating data bytes into meaningful primitive-type units. FilterInputStream and FilterOutputStream are typically extended, so some of their filtering capabilities are provided by their concrete subclasses.
D) A PrintStream performs text output. System.out and System.err are PrintStreams.
سؤال
________ 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
سؤال
Which FileChooser method returns the file the user selected?

A) getSelectedFile.
B) getFile.
C) getOpenDialog.
D) showOpenDialog.
سؤال
Which DirectoryChooser method returns the folder the user selected?

A) getSelectedfolder.
B) showDialog.
C) getOpenDialog.
D) showOpenDialog.
سؤال
JAXB's static method ________ deserializes objects from XML.

A) fromXML
B) deserialize
C) unmarshal
D) None of the above
سؤال
JAXB's static method ________ serialize objects as XML.

A) toXML
B) serialize
C) marshal
D) None of the above
سؤال
Which of the following statements is false?

A) A LineNumberReader is a buffered character stream that tracks the number of lines read.
B) Classes FileReader and FileWriter perform character-based file I/O.
C) Class PipedReader and class PipedWriter implement piped-character streams for transferring data between threads.
D) Class StringReader and StringWriter read characters from and write characters to Streams, respectively.
سؤال
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.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/30
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 15: Files, Inputoutput Streams, Nio and Xml Serialization
1
Which of the following is false?

A) JAXB (Java Architecture for XML Binding) enables you to perform XML serialization.
B) Marshaling is the process of deserializing an object.
C) A serialized object is represented by XML that includes the object's data.
D) XML (eXtensible Markup Language) is a widely used language for describing data.
B
2
Which of the following statements is false?

A) Path method isAbsolute returns a boolean indicating whether a Path represents an absolute path to a file or directory.
B) Files static method getLastModifiedTime receives a Path and returns a FileTime (package java.nio.file.attribute) indicating when the file was last modified.
C) Files static method size receives a Path and returns a long representing the number of bytes in the file or directory. For directories, the value returned is platform specific.
D) All of the above are true.
D
3
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
all the data in the file is discarded
4
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
6
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
7
Which of the following is false?

A) JAXB works with POJOs (plain old Java objects)-no special superclasses or interfaces are required for XML-serialization support.
B) JAXB serializes only an object's public instance variables and public read-write properties.
C) A class must provide a public default or no-argument constructor to recreate the objects when they're read from the file.
D) JAXB requires you to implement special superclasses and interfaces for XML-serialization support.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
8
Path method ________ returns the String name of a file or directory without any location information.

A) getStringName
B) getFileOrDirectoryName
C) getDirectoryName
D) getFileName
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
9
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
10
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
11
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
12
A(n) ________ path starts from the directory in which the application began executing.

A) absolute
B) relative
C) parallel
D) comparative
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
13
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
14
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
15
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
16
A serialized object is ________.

A) an object represented by XML that includes the object's data.
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
17
The annotation ________ indicates that a private instance variable should be serialized.

A) @XMLElement
B) @Element
C) @Marshal
D) @Serialize
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
18
Which of the following classes is not used for file input?

A) FileInputStream
B) FileReader
C) ObjectInputStream
D) Formatter
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
19
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
20
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
21
JavaFX classes ________ and ________ (package javafx.stage) display dialogs that enable the user to select a file or directory, respectively.

A) Files, Directories
B) FileChooser, DirectoryChooser
C) FileSelector, DirectorySelector
D) None of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
22
The ________ abstract classes are Unicode character-based streams.

A) Reader and Writer
B) BufferedReader and BufferedWriter
C) CharArrayReader and CharArrayWriter
D) UnicodeReader and UnicodeWriter
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
23
Which of the following statements is false?

A) InputStream and OutputStream are abstract classes for performing byte-based I/O.
B) Tubes are synchronized communication channels between threads.
C) A filter stream provides additional functionality, such as aggregating data bytes into meaningful primitive-type units. FilterInputStream and FilterOutputStream are typically extended, so some of their filtering capabilities are provided by their concrete subclasses.
D) A PrintStream performs text output. System.out and System.err are PrintStreams.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
24
________ 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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
25
Which FileChooser method returns the file the user selected?

A) getSelectedFile.
B) getFile.
C) getOpenDialog.
D) showOpenDialog.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
26
Which DirectoryChooser method returns the folder the user selected?

A) getSelectedfolder.
B) showDialog.
C) getOpenDialog.
D) showOpenDialog.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
27
JAXB's static method ________ deserializes objects from XML.

A) fromXML
B) deserialize
C) unmarshal
D) None of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
28
JAXB's static method ________ serialize objects as XML.

A) toXML
B) serialize
C) marshal
D) None of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
29
Which of the following statements is false?

A) A LineNumberReader is a buffered character stream that tracks the number of lines read.
B) Classes FileReader and FileWriter perform character-based file I/O.
C) Class PipedReader and class PipedWriter implement piped-character streams for transferring data between threads.
D) Class StringReader and StringWriter read characters from and write characters to Streams, respectively.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
30
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.