1Z0-829 Java I/O API and Securing Applications Practice Question
Which TWO statements are true regarding reading files with the NIO.2 API?
⚠ Common exam trap
Oracle often tests the distinction between memory-hungry convenience methods (`readAllLines`, `readAllBytes`) and streaming approaches (`lines`, `newBufferedReader`), trapping candidates who assume 'readAll' methods are efficient for large files.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Files.newBufferedReader() provides buffered character input.
`Files.newBufferedReader()` returns a `BufferedReader` that wraps a `FileReader` (or underlying `FileChannel`), providing efficient buffered character input. This method is designed for reading text files line-by-line with reduced I/O operations, making it suitable for large or stream-oriented text processing.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Files.readAllLines() is memory efficient for large files.
Why it's wrong here
readAllLines loads all lines into memory, which is not efficient.
- ✓
Files.newBufferedReader() provides buffered character input.
Why this is correct
newBufferedReader returns a BufferedReader for efficient reading.
- ✓
Files.lines() with try-with-resources allows streaming of lines.
Why this is correct
lines() returns a Stream that processes lines lazily.
- ✗
Files.newInputStream() wraps a FileChannel for high performance.
Why it's wrong here
newInputStream returns an InputStream, not a FileChannel; not necessarily high performance.
- ✗
Files.readAllBytes() is the best choice for large binary files.
Why it's wrong here
readAllBytes loads entire file into memory, not suitable for large files.
Go deeper
Related to this question
About these practice questions
Courseiva writes every 1Z0-829 question from scratch — 513 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This 1Z0-829 practice question is part of Courseiva's free Oracle certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 1Z0-829 exam.