Java OCA OCP Practice Question 824

Question

Which of these array declarations and initializations are NOT legal?

Select 2 options

  • A. int[] i[] = { { 999, 9999 }, { 999 }, { }, { 999, 9999, 99999 } } ;
  • B. int i[] = new int [2] {999, 9999} ;
  • C. int i[][] = new int [][] { {999, 9999, 99999}, {4, 5, 6} } ;
  • D. int i[][] = { { 999, 9999 }, new int [ 9999 ] } ;
  • E. int i[4] = { 999, 9999, 99999, 4 } ;


Correct Options are  : B E

Note

If you explicitly specify the members then you can't give the size.

So option 2 is wrong.

The size of the array is never given during the declaration of an array reference.

So option 5 is wrong.

The size of an array is always associated with the array instance, not the array reference.




PreviousNext

Related