Java OCA OCP Practice Question 964

Question

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

public class Main {
   public static void main(String[] args) {
      int i = 1;//from   www  .  j ava  2 s.c om
      int j = 2;
      outer: while (i < j) {
         ++i;
         inner: do {
            ++j;
            if (i++ % 3 == 2)
               break inner;
            else if (j++ % 3 == 1)
               break outer;
            System.out.println(i * j);
         } while (j < i);
         System.out.println(i + j);
      }
   }
}
  • A. 5
  • B. 6
  • C. 7
  • D. The program does not display any output.


B.

Note

The program displays the value 6.




PreviousNext

Related