1Z0-829 Java I/O API and Securing Applications Practice Question
A developer needs to read a very large text file (over 1 GB) efficiently with minimal memory overhead. Which approach is most suitable?
⚠ Common exam trap
Many candidates choose BufferedReader for its simplicity, not realizing that reading lines from a multi-GB file still requires holding entire lines in memory, which can cause OutOfMemoryError or severe performance degradation.
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
✓
Use FileChannel with a ByteBuffer to read in chunks.
FileChannel with a ByteBuffer allows reading a large file in configurable chunks, leveraging the operating system's native I/O for high throughput and minimal memory overhead. This approach avoids loading the entire file into memory and reduces context switching compared to stream-based readers.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Use Scanner to read tokens.
Why it's wrong here
Scanner is not designed for high-performance file reading; it's for parsing.
- ✗
Use BufferedReader to read lines.
Why it's wrong here
BufferedReader loads lines into memory; for large files, this can be memory-intensive.
- ✗
Use FileInputStream and read byte by byte.
Why it's wrong here
Reading byte by byte is extremely inefficient for large files.
- ✓
Use FileChannel with a ByteBuffer to read in chunks.
Why this is correct
FileChannel with ByteBuffer allows efficient chunked reading, minimizing memory usage.
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.