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

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

Mastering Java: The Ultimate Quiz for 'Thinking in Java'. Dive deep into Java with multiple-choice questions. Challenge yourself with quiz questions designed to test and improve your understanding of the 'Thinking in Java' book. Get ready for your exam!

Practice this question and more.


What does the FileWriter class do?

  1. Writes bytes to a file

  2. Writes characters to a file

  3. Reads characters from a file

  4. Reads bytes from a file

The correct answer is: Writes characters to a file

The FileWriter class is specially designed for writing characters to a file. It is used to write text to a character-based output stream, making it unsuitable for writing bytes to a file. The other options are incorrect because they do not accurately describe the purpose of the FileWriter class. FileWriter is not used for reading characters or bytes from a file, but rather for writing data to a file. Therefore, the correct answer is B.