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








Question

Which of the following statement will compile?

        int i = 5; 
        int j = 10; 
  1. while(i < j) {}
  2. while(i) {}
  3. while(i = 5) {}
  4. while((i = 12)!=5) {}




Answer



A and D

Note

while() in Java only accepts expression evaluated to a Boolean value.