Java OCA OCP Practice Question 974

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  w w  w. j  a  va2  s  .  c o  m*/
      int j = 2;
      outer: while (i < j) {
         ++i;
         inner: do {
            ++j;
            if (j % 3 == 0)
               continue outer;
            if (i % 3 == 0)
               break inner;
            if (i % 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.


C.

Note

The program displays the value 7.




PreviousNext

Related