| 1. | What is the purpose of the File class? Can the File class be used to create an actual file? If so, how? | |
| 2. | What are the primary differences between the byte-stream classes and the character-stream classes? | |
| 3. | What is meant by the term data sink? What is meant by the term data source? | |
| 4. | What’s the purpose of any java.io class that contains the word Buffer in its name? What is the default buffer size for any such class? | |
| 5. | In your own words describe what is meant by the terms file terminal class, intermediate class, and user fronting class. | |
| 6. | (True/False) The RandomAccessFile class can be used to write serializable objects to a file. | |
| 7. | What combination of classes can be used to write and read serializable objects to and from a file? | |
| 8. | What classes can be used to write textual representations of primitive types and objects to a file? | |
| 9. | What interface must an object implement before it can be serialized to a file? | |
| 10. | What classes in the java.io package implement the DataInput or DataOutput interface? | |
Answers
| 1. | - The File class represents the name of a file or directory. Yes, the File class can be used to create empty files and directories using the appropriate methods. |
| 2. | - Character stream class should be favored when manipulating large amounts of character data and you need to control character encoding. |
| 3. | - A sink is a destination to which data is being sent to; a source is an origination point from which data is being read. |
| 4. | - Improves the efficiency of reads and writes by caching data and writing or reading when the buffer is flushed. |
| 5. | - a file terminal class is a java.io class that takes the name of the file as an argument to its constructor; An intermediate class is one that is used in conjunction with a file-terminal class to provide augmented functionality but does not possess sufficient user interface methods to make it a user-fronting class; User-fronting classes provide numerous user interface methods. |
| 6. | - false |
| 7. | - FileOutputStream, BufferedOutputStream, ObjectOutputStream |
| 8. | - PrintWriter, PrintStream |
| 9. | - Serializable |
| 10. | - DataInputStream, DataOutputStream |