ch 17 Ha

Ace your homework & exams now with Quizwiz!

Which of the following is the legal mode for creating a new RandomAccessFile stream?

"rw"

Which of the following statements are true?

A File object encapsulates the properties of a file or a path, but does not contain the methods for reading/writing. You can use the PrintWriter class for outputting text to a file. You can use the Scanner class for reading text from a file. An input object is also called an input stream. An output object is also called an output stream.

Which of the following statements are true?

All files are stored in binary format. So, all files are essentially binary files. Text I/O is built upon binary I/O to provide a level of abstraction for character encoding and decoding. Encoding and decoding are automatically performed by text I/O. For binary input, you need to know exactly how data were written in order to read them in correct type and order.

Which of the following statements are true?

All methods in FileInputStream/FileOutputStream are inherited from InputStream/OutputStream. You can create a FileInputStream/FileOutputStream from a File object or a file name using FileInputStream/FileOutputStream constructors. The return value -1 from the read() method signifies the end of file. A java.io.FileNotFoundException would occur if you attempt to create a FileInputStream with a nonexistent file.

Which of the following statements is correct to create a DataOutputStream to write to a file named out.dat?

DataOutputStream outfile = new DataOutputStream(new FileOutputStream("out.dat"));

Which type of exception occurs when creating a DataInputStream for a nonexistent file?

FileNotFoundException

What does the following code do? FileInputStream fis = new FileInputStream("test.dat");

It creates a FileInputStream for test.dat if test.dat exists.

Which of the following statements are true?

ObjectInputStream/ObjectOutputStream enables you to perform I/O for objects in addition for primitive type values and strings. Since ObjectInputStream/ObjectOutputStream contains all the functions of DataInputStream/DataOutputStream, you can replace DataInputStream/DataOutputStream completely by ObjectInputStream/ObjectOutputStream. To write an object, the object must be serializable. The Serializable interface does not contain any methods. So it is a mark interface. If all the elements in an array is serializable, the array is serializable too.

Which of the following statements is true?

RandomAccessFile

With which I/O class can you append or update a file?

RandomAccessFile()

Which of the following statements are true?

Text I/O is built upon binary I/O to provide a level of abstraction for character encoding and decoding. Text I/O involves encoding and decoding. Binary I/O does not require conversions. Binary I/O is more efficient than text I/O, because binary I/O does not require encoding and decoding. Binary files are independent of the encoding scheme on the host machine and thus are portable.

Which method can you use to find out the number of the bytes in a file using InputStream?

available()

To append data to an existing file, use _____________ to construct a FileOutputStream for file out.dat.

new FileOutputStream("out.dat", true)


Related study sets

Salesforce Design Strategy - Tools and Artifacts

View Set

BUS 101 Final Exam (Chapters 9, 17-20, and D, and Lecture Notes)-FINNIN

View Set

CNF Exam 2: Fluid, Electrolyte, Acid-Base Balance (39)

View Set

GLY1010 Chapter 6 Test - Weathering and Soil

View Set