🎙 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 4 of 10

Why is readAllLines a bad choice for a 5 GB log file?

Why is readAllLines a bad choice for a 5 GB log file?

  1. A.It only reads the first 1,000 lines
  2. B.It cannot read .log files
  3. C.It loads every line into memory at once, which can cause OutOfMemoryError
  4. D.It deletes the file after reading
Answer & explanation

Correct answer: It loads every line into memory at once, which can cause OutOfMemoryError

For big files, read one line at a time with BufferedReader or Files.lines.

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 →