OCA Java SE 8 Mock Exam 2 - OCA Mock Question 16








Question

Which of the following if statements will compile without errors?

     int i = 3; 
     int j = 3; 
     int k = 3; 
  1. if(i > j) {}
  2. if(i > j > k) {}
  3. if(i > j && i > k) {}
  4. if(i > j && > k) {}




Answer



A and C

Note

B results in a comparison between i and j which returns a Boolean value.

This value cannot be compared against the integer k.

D requires an operand before the expression > k.