OCA Java SE 8 Mock Exam 2 - OCA Mock Question 6








Question

Which of the following statements will compile without an error?

  1. int myArray[];
  2. int myArray[5];
  3. int myArray[5] = {1,2,3,4,5};
  4. int myArray[] = {1,2,3,4,5};




Answer



a and d

Note

The correct declaration is as follows.

int myArray[] = new int[5];