Java OCA OCP Practice Question 9

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.

Note

The program displays the value 5. It does not display the values 8 or 13.




PreviousNext

Related