1Z0-811 Java Basics and Syntax Practice Question
Given the code: int[] arr = {1,2,3}; for(int x : arr) { if(x==2) continue; System.out.print(x); } What is the output?
⚠ Common exam trap
Many candidates confuse continue with break, thinking continue terminates the loop entirely, or they forget that continue skips only the current iteration's remaining code, leading them to include the skipped value in the output.
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
✓
13
The enhanced for loop iterates over the array {1,2,3}. When x equals 2, the continue statement skips the remainder of the loop body for that iteration, so System.out.print(x) is not executed for 2. Thus, only 1 and 3 are printed, producing output '13'.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
2
Why it's wrong here
2 is skipped.
- ✗
Compilation error
Why it's wrong here
Code compiles.
- ✓
13
Why this is correct
1 and 3 are printed.
- ✗
123
Why it's wrong here
2 is skipped.
Go deeper
Related to this question
About these practice questions
This 1Z0-811 question is part of Courseiva's 481-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam 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-811 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-811 exam.