1Z0-804 · Question #60
Which code fragment correctly appends "Java 7" to the end of the file /tmp/msg.txt?
The correct answer is B. FileWriter w = new FileWriter("/tmp/msg.txt", true). FileWriter(File file, boolean append) A: clears the file and append "Java7" Constructs a FileWriter object given a File object. If the second argument is true, then bytes will be written to the end of the file rather than the beginning.Parameters: file - a File object to write…
Question
Which code fragment correctly appends "Java 7" to the end of the file /tmp/msg.txt?
Options
- AFileWriter w = new FileWriter("/tmp/msg.txt");
- BFileWriter w = new FileWriter("/tmp/msg.txt", true);
- CFileWriter w = new FileWriter("/tmp/msg.txt", FileWriter.MODE_APPEND);
- DFileWriter w = new FileWriter("/tmp/msg.txt", Writer.MODE_APPEND);
How the community answered
(22 responses)- A9% (2)
- B82% (18)
- C5% (1)
- D5% (1)
Explanation
FileWriter(File file, boolean append) A: clears the file and append "Java7" Constructs a FileWriter object given a File object. If the second argument is true, then bytes will be written to the end of the file rather than the beginning.Parameters: file - a File object to write toappend - if true, then bytes will be written to the end of the file rather than the beginning
Topics
Community Discussion
No community discussion yet for this question.