Courseiva
Control Flow and LoopseasyMultiple SelectObjective-mapped

1Z0-811 Control Flow and Loops Practice Question

Which TWO of the following are valid loop constructs in Java? (Choose two.)

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

do {} while (false);

A valid do-while loop; the semicolon after the condition is required. Option E is a standard for loop. Option B is invalid because 'while (true)' lacks a loop body (statement or block). Option C uses incorrect syntax: 'for each' is not Java; the correct syntax is 'for (int i : array)'. Option D uses 'loop' which is not a Java keyword; the correct keyword is 'for'.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • do {} while (false);

    Why this is correct

    Correct do-while loop syntax, including the required semicolon.

  • while (true)

    Why it's wrong here

    Missing statement or block after while condition; causes compilation error.

  • for each (int i : array) {}

    Why it's wrong here

    Java uses 'for (int i : array)' not 'for each'.

  • loop (int i = 0; i < 10; i++) {}

    Why it's wrong here

    'loop' is not a Java keyword; use 'for' instead.

  • for (int i = 0; i < 10; i++) {}

    Why this is correct

    Correct syntax for a for loop.

About these practice questions

One of 481 original 1Z0-811 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-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.