🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: File Handling in Java: all 10 questions

Quiz: File Handling in Java · Question 7 of 10

You write lines with a BufferedWriter but never close or flush it. What can happen?

You write lines with a BufferedWriter but never close or flush it. What can happen?

  1. A.Nothing; data is written immediately
  2. B.The program does not compile
  3. C.The last lines may stay in the buffer and never reach the file
  4. D.The file is deleted
Answer & explanation

Correct answer: The last lines may stay in the buffer and never reach the file

Data reaches the file when the buffer fills, or on flush/close. Try-with-resources closes it for you.

Can you get the rest right without peeking?

Take the timed Quiz: File Handling in Java quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →