OCA Java SE 8 Operators/Statements - OCA Mock Question Operator and Statement 13
Question
What is the output of the following code snippet?
public class Main{
public static void main(String[] argv){
3: int x = 1, y = 5;
4: while x < 8
5: y--;
6: x++;
7: System.out.println(x+", "+y);
}
}
- 7, 5
- 7, 6
- 7, 5
- The code will not compile because of line 3.
- The code will not compile because of line 4.
- The code contains an infinite loop and does not terminate.
Answer
Note
The while statement on line 4 is missing parentheses.