Java OCA OCP Practice Question 2728

Question

Which of the following statements will compile without an error?

  • a. int arr[];
  • b. int arr[5];
  • c. int arr[5] = {1,2,3,4,5};
  • d. int arr[] = {1,2,3,4,5};


a and d

Note

The number of elements in an array declaration is not used in the declaration.

However, we can use the following:.

int arr[] = new int[5];



PreviousNext

Related