OCA Java SE 8 Mock Exam 2 - OCA Mock Question 6
Question
Which of the following statements will compile without an error?
- int myArray[];
- int myArray[5];
- int myArray[5] = {1,2,3,4,5};
- int myArray[] = {1,2,3,4,5};
Answer
Note
The correct declaration is as follows.
int myArray[] = new int[5];