Chapter One Questions
Chapter One Questions
a. Writer
b. OutputStream
c. FileWriter
d. BufferedWriter
A
3. For characters from the English (Roman) alphabet, how many bytes are used per
character in the Program and how many are used on a disk file?
a. program: 1 disk file: 1
b. program: 1 disk file: 2
c. program: 2 disk file: 1
d. program: 2 disk file: 2
C
5. When a file is opened for appending where does write() put new text?
a. At the beginning of the file.
b. At the end of the file.
c. Where ever the user specifies.
d. Files cannot be appended to.
B
7. What class should be used to buffer the characters sent to a FileWriter stream?
a. BufferedFileWriter
b. BufferedWriter
c. Writer
d. Buffer
B
8. What method a buffered character stream sends the correct characters for
terminating a line of text on the computer running the program?
a. buf.write("\n");
b. buf.writeLine();
c. buf.newLine();
d. buf.putLine();
C
9. What method ensures that data from previous calls to write() is sent to disk and
leaves the file open?
a. flush()
b. close()
c. Each write() does this for the previous one.
d. print()
A
10. Can a text file written by a Java program be read by programs written in other
languages?
a. No---Java uses its own text file format.
b. No---the ends of lines will be completely different.
c. Yes---usually there will be no problem.
d. Yes---this is always possible without any problems.
C