Java OCA OCP Practice Question 979

Question

If you ran the following program, what lines would be included in its output?

class Question {
   public static void main(String[] args) {
      int i, j;
      for (i = 0, j = 0; i + j < 20; ++i, j += i--) {
         System.out.println(i + j);
      }
   }

}
  • A. 5
  • B. 8
  • C. 13
  • D. The program cannot be compiled because the for statement's syntax is incorrect.


A, B, and C.

Note

The program displays the values 5, 8, and 13.




PreviousNext

Related