OCA Java SE 8 Operators/Statements - OCA Mock Question Operator and Statement 4








Question

What is the output of the following code snippet?

     3: int x = 4; 
     4: long y = x * 4 - x++ + --x; 
     5: if(y<10) System.out.println("A"); 
     6: else System.out.println("B"); 
     7: else System.out.println("C"); 
  1. A
  2. B
  3. C
  4. The code will not compile because of line 6.
  5. The code will not compile because of line 7.




Answer



E.

Note

The code does not compile since there are two else statements without additional if-then statements.