← 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?
- A.It only reads the first 1,000 lines
- B.It cannot read .log files
- C.It loads every line into memory at once, which can cause OutOfMemoryError
- 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 →