Java OCA OCP Practice Question 984

Question

What is wrong with the following statements:

public class Main {
   public static void main(String[] args) {
      int[] x = new int[100];
      int[] y = new int[100];
      for (int i = 0; i < 10; ++i) {

         if (x[i] > 100)
            break;

         if (x[i] < 0)
            continue;

         x[i + 1] = x[i] + y[i];// ww w  . j  a v a2 s . c  o m
      }
   }
} 
  • A. It is illegal to have a break and continue statement within the same for statement.
  • B. The i variable cannot be declared in the initialization part of a for statement.
  • C. The prefix operator is not allowed in the iteration part of a for statement.
  • D. There's nothing wrong with the statements.


D.

Note

There's nothing wrong with the statements.




PreviousNext

Related