1Z0-829 Controlling Program Flow • Set 2
1Z0-829 Controlling Program Flow Practice Test 2 — 15 questions with explanations. Free, no signup.
A Java developer is writing a batch processing application that reads records from a database and processes them. The processing must continue even if some records cause exceptions (e.g., data conversion errors). However, the application must log each failed record and its error, then continue with the next record. The developer uses a for loop to iterate over a list of records. Inside the loop, a try-catch block wraps the processing logic. After implementing, the developer notices that when an exception occurs, the loop terminates prematurely instead of continuing. The code structure is:
List<Record> records = fetchRecords();
for (Record rec : records) {try { process(rec);
} catch (Exception e) {log.error("Failed to process: " + rec.getId(), e);
}
}What is the most likely reason for the premature termination?