Courseiva
Java I/O API and Securing ApplicationshardMultiple ChoiceObjective-mapped

1Z0-829 Java I/O API and Securing Applications Practice Question

An architect is designing a microservice that reads large CSV files (up to 500 MB) from a shared filesystem and processes each row. The processing is CPU-bound and must not block the main thread. The service is deployed in a container with limited memory (512 MB heap). Which approach is most suitable?

⚠ Common exam trap

Many candidates assume memory-mapped files (FileChannel) are always efficient for large files, but they ignore the memory constraint and the need to keep the main thread responsive; Oracle tests whether you understand that bounded queues and separate threads are required for back-pressure and non-blocking processing in constrained environments.

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 a BufferedReader on a separate thread, reading lines into a bounded queue, and a thread pool to process rows from the queue.

It uses a bounded blocking queue to decouple I/O (reading lines from the CSV) from CPU-bound processing, preventing the main thread from being blocked while also avoiding memory exhaustion. The bounded queue acts as a back-pressure mechanism, ensuring that the limited 512 MB heap is not overwhelmed by the 500 MB file. Processing rows via a thread pool allows parallel CPU-bound work without blocking the reading thread.

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 Files.readAllLines() to read the entire file into memory, then process in parallel using streams.

    Why it's wrong here

    readAllLines() loads the entire file into memory, causing OOM with large files and limited heap.

  • Use a BufferedReader on a separate thread, reading lines into a bounded queue, and a thread pool to process rows from the queue.

    Why this is correct

    This approach reads line by line, using a bounded queue to decouple reading and processing.

  • Use a FileChannel with a memory-mapped byte buffer of the entire file.

    Why it's wrong here

    Memory-mapping the entire file would also exceed the heap (maps are off-heap but still consume address space; could cause issues).

  • Use a java.nio.file.FileSystem with a WatchService to detect changes to the file.

    Why it's wrong here

    WatchService is for monitoring directory changes, not for reading file contents.

About these practice questions

One of 513 original 1Z0-829 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

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.