Given the for loop construct:

for ( expr1 ; expr2 ; expr3 ) {
    statement;
}

Which two statements are true?

A. This is not the only valid for loop construct; there exits another form of for loop constructor.
B. The expression expr1 is optional. it initializes the loop and is evaluated once, as the loop begin.
C. When expr2 evaluates to false, the loop terminates. It is evaluated only after each iteration through the loop.
D. The expression expr3 must be present. It is evaluated after each iteration through the loop.

题解

选项 A,叙述正确,还有 foreach 的结构,如下:

for ( expr1 : expr2) {
    statement;
}

选项 B,叙述正确,expr1 是用来初始化 for 循环会用到的变量。

选项 C,每次要进入循环之前就会判断 expr2,而不是每次循环运行之后。每次循环运行之后才判断 expr2,比较像是 do-while 的结构。

选项 D,expr3 可以省略没有关系。