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); 
   
   }
}

  1. 7, 5
  2. 7, 6
  3. 7, 5
  4. The code will not compile because of line 3.
  5. The code will not compile because of line 4.
  6. The code contains an infinite loop and does not terminate.




Answer



E.

Note

The while statement on line 4 is missing parentheses.