PRASHNIKAप्रश्निका
‹ Back to the paper

What is the difference between the following two statements? 1. `FileWriter fw = new…

Computer Science20252 marksShort answer
What is the difference between the following two statements? 1. `FileWriter fw = new FileWriter(<file name>);` 2. `FileWriter fw = new FileWriter(<file name>, true);`

Answer

Answer

AI
FileWriter fw = new FileWriter(<file name>); opens the file for writing and, if the file already exists, erases (overwrites) its existing content before writing. FileWriter fw = new FileWriter(<file name>, true); opens the file in append mode: the existing content is kept, and new data is written starting after the end of the file.
Objects

From ISC Computer Science - Competency Focused Practice Questions (CISCE, August 2024), question 59.