Deck 17: Files,streams and Object Serialization

ملء الشاشة (f)
exit full mode
سؤال
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.
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
What does the following statement do? Scanner scanner = new Scanner( new File( "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.
سؤال
Which of the following is arranged in increasing size order?

A)field,bit,file,record.
B)byte,file,database,record.
C)byte,field,file,record.
D)bit,field,record,file.
سؤال
Which of the following statements is false?

A)The smallest data item a computer can assume is the value 0 or the value 1.
B)The term "bit" is short for "byte digit."
C)Java uses the Unicode character set.
D)A record is typically composed of several fields.
سؤال
Which of the following statements is not equivalent to File name = new File( "c:\\books\\2009\\files.txt" );
Assume we are currently in the directory c:\books.

A)File name = new File( "c:\\books\\2009","files.txt" );
B)File name = new File( "files.txt" );
C)File name = new File( "2009","files.txt" );
D)All of the above are equivalent to the statement in the question.
سؤال
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)IOOutput.
سؤال
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
سؤال
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.
سؤال
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.
سؤال
Which of the following is not an application of a File object?

A)Open or edit a file.
B)Determine if a file exists.
C)Determine whether a file is readable.
D)Determine whether a file is writable.
سؤال
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 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.
سؤال
Adding the services of one stream to another is known as

A)chaining.
B)wrapping.
C)adding.
D)sequencing.
سؤال
Relative paths normally start from which directory?

A)The directory in which the application began executing.
B)The root directory.
C)The directory in which the Java interpreter is installed.
D)None of the above.
سؤال
What happens when an end-of-file marker is reached (and the program is using an ObjectInputStream to read data from a file)?

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.
سؤال
Which of the following classes is not used for file input?

A)FileInputStream
B)FileReader
C)ObjectInputStream
D)Formatter
سؤال
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.
سؤال
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 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 method call enables users to specify that a user can select files and directories from a JFileChooser?

A)setFileSelectionMode( FILES_OR_DIRECTORIES );
B)showOpenDialog( FILES_AND_DIRECTORIES );
C)showOpenDialog( FILES_OR_DIRECTORIES );
D)None of the above.
سؤال
Which JFileChooser method returns the file the user selected.

A)getSelectedFile.
B)getFile.
C)getOpenDialog.
D)showOpenDialog.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/22
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 17: Files,streams and Object Serialization
1
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.
B
2
What does the following statement do? Scanner scanner = new Scanner( new File( "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
3
Which of the following is arranged in increasing size order?

A)field,bit,file,record.
B)byte,file,database,record.
C)byte,field,file,record.
D)bit,field,record,file.
D
4
Which of the following statements is false?

A)The smallest data item a computer can assume is the value 0 or the value 1.
B)The term "bit" is short for "byte digit."
C)Java uses the Unicode character set.
D)A record is typically composed of several fields.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 22 في هذه المجموعة.
فتح الحزمة
k this deck
5
Which of the following statements is not equivalent to File name = new File( "c:\\books\\2009\\files.txt" );
Assume we are currently in the directory c:\books.

A)File name = new File( "c:\\books\\2009","files.txt" );
B)File name = new File( "files.txt" );
C)File name = new File( "2009","files.txt" );
D)All of the above are equivalent to the statement in the question.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 22 في هذه المجموعة.
فتح الحزمة
k this deck
6
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)IOOutput.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 22 في هذه المجموعة.
فتح الحزمة
k this deck
7
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 22 في هذه المجموعة.
فتح الحزمة
k this deck
8
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 22 في هذه المجموعة.
فتح الحزمة
k this deck
9
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 22 في هذه المجموعة.
فتح الحزمة
k this deck
10
Which of the following is not an application of a File object?

A)Open or edit a file.
B)Determine if a file exists.
C)Determine whether a file is readable.
D)Determine whether a file is writable.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 22 في هذه المجموعة.
فتح الحزمة
k this deck
11
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 22 في هذه المجموعة.
فتح الحزمة
k this deck
12
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 22 في هذه المجموعة.
فتح الحزمة
k this deck
13
Adding the services of one stream to another is known as

A)chaining.
B)wrapping.
C)adding.
D)sequencing.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 22 في هذه المجموعة.
فتح الحزمة
k this deck
14
Relative paths normally start from which directory?

A)The directory in which the application began executing.
B)The root directory.
C)The directory in which the Java interpreter is installed.
D)None of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 22 في هذه المجموعة.
فتح الحزمة
k this deck
15
What happens when an end-of-file marker is reached (and the program is using an ObjectInputStream to read data from a file)?

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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 22 في هذه المجموعة.
فتح الحزمة
k this deck
16
Which of the following classes is not used for file input?

A)FileInputStream
B)FileReader
C)ObjectInputStream
D)Formatter
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 22 في هذه المجموعة.
فتح الحزمة
k this deck
17
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 22 في هذه المجموعة.
فتح الحزمة
k this deck
18
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 22 في هذه المجموعة.
فتح الحزمة
k this deck
19
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 22 في هذه المجموعة.
فتح الحزمة
k this deck
20
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 22 في هذه المجموعة.
فتح الحزمة
k this deck
21
Which method call enables users to specify that a user can select files and directories from a JFileChooser?

A)setFileSelectionMode( FILES_OR_DIRECTORIES );
B)showOpenDialog( FILES_AND_DIRECTORIES );
C)showOpenDialog( FILES_OR_DIRECTORIES );
D)None of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 22 في هذه المجموعة.
فتح الحزمة
k this deck
22
Which JFileChooser method returns the file the user selected.

A)getSelectedFile.
B)getFile.
C)getOpenDialog.
D)showOpenDialog.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 22 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 22 في هذه المجموعة.