1Z0-803 · Question #94
1Z0-803 Question #94: Real Exam Question with Answer & Explanation
The correct answer is B: The expression expr1 is optional.. The for statement have this forms: for (init-stmt; condition; next-stmt) { There are three clauses in the for statement. The init-stmt statement is done before the loop is started, usually to initialize an iteration The condition expression is tested before each time the loop is
Question
Options
- AThis is not the only valid for loop construct; there exits another form of for loop constructor.
- BThe expression expr1 is optional.
- CWhen expr2 evaluates to false, the loop terminates.
- DThe expression expr3 must be present.
Explanation
The for statement have this forms: for (init-stmt; condition; next-stmt) { There are three clauses in the for statement. The init-stmt statement is done before the loop is started, usually to initialize an iteration The condition expression is tested before each time the loop is done. The loop isn't executed if the boolean expression is false (the same as the while loop). The next-stmt statement is done after the body is executed. It typically increments an iteration variable. Incorrect answers: A: A try for a counter-example: for (int 1 : a) { This is a correct statement. However, Expr2 and Expr3 are here empty expressions, so it is still in the format defined above.
Community Discussion
No community discussion yet for this question.