1Z0-815 · Question #108
Given the for loop construct: for ( expr1 ; expr2 ; expr3 ) { statement; } Which two statements are true?
The correct answer is A. This is not the only valid for loop construct; there exits another form of for loop constructor. B. The expression expr1 is optional. A is true because there are two types of for loop in Java. Classic and Enhanced. B is true because we can run code like for( ; expr2 ; expr3). C is false because expr2 is evaluated BEFORE each iteration. D is false because we can run code like for(expr1; expr2; ).
Question
Given the for loop construct:
for ( expr1 ; expr2 ; expr3 ) { statement; } Which two statements are true?
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.
How the community answered
(37 responses)- A81% (30)
- C14% (5)
- D5% (2)
Explanation
A is true because there are two types of for loop in Java. Classic and Enhanced. B is true because we can run code like for( ; expr2 ; expr3). C is false because expr2 is evaluated BEFORE each iteration. D is false because we can run code like for(expr1; expr2; ).
Topics
Community Discussion
No community discussion yet for this question.