Mastering Java: The Ultimate Quiz for 'Thinking in Java'

Disable ads (and more) with a membership for a one time $2.99 payment

Prepare for your Java exam with our ultimate quiz based on 'Thinking in Java'. Engage with expertly crafted questions that enhance your learning process. Perfect for Java enthusiasts looking to solidify their knowledge!

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


Which classes are recommended for file input and output in the given examples?

  1. BufferedInputStream and BufferedOutputStream

  2. FileReader and FileWriter

  3. FileInputStream and FileOutputStream

  4. DataInputStream and DataOutputStream

The correct answer is: FileReader and FileWriter

FileReader and FileWriter are recommended for file input and output because they are used for manipulating character files. BufferedInputStream and BufferedOutputStream are used to improve performance while reading and writing bytes from a file, but not specifically for handling character files like in the given examples. Similarly, FileInputStream and FileOutputStream are used for reading from and writing to binary files, not necessarily for character files. DataInputStream and DataOutputStream are used for reading primitive data types from a binary stream, not for file input and output. Therefore, FileReader and FileWriter are the most appropriate classes for file input and output in the given examples.