Hi Geethakrishna,
The statement:
for ( ; false ; ); According to
JLS2 14.20 Unreachable Statements, that statement is considered unreachable.
for statement can complete normally iff at least one of the following is true:
The for statement is reachable, there is a condition expression, and the condition expression is not a constant expression with value true. There is a reachable break statement that exits the for statement.
The contained statement is reachable iff the for statement is reachable and the condition expression is not a constant expression whose value is false.
Since you're preparing for SCJP 1.4, I think it's safe as long as we follow the rules specified in JLS 2. So if being asked, I'd choose the one that gives unreachable error as the correct behavior from the compiler. Check out this
bug report as well.
If you're preparing for SCJP 5.0, you'll have to refer to
JLS 3rd edition.
Joyce
[ June 24, 2005: Message edited by: Joyce Lee ]