🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Exceptions and Files: all 15 questions

Quiz: Exceptions and Files · Question 3 of 15

What does opening an existing file with mode "w" do?

What does opening an existing file with mode "w" do?

  1. A.Adds to the end
  2. B.Erases its contents first
  3. C.Opens it read-only
  4. D.Raises an error
Answer & explanation

Correct answer: Erases its contents first

"w" creates or truncates the file. Use "a" to add to the end.

Can you get the rest right without peeking?

Take the timed Quiz: Exceptions and Files quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →