Java OCA OCP Practice Question 1396

Question

Consider the following array definitions:

int [] array1, array2 []; 
int [][] array3; 
int [] array4 [], array5 []; 

Which of the following are valid statements?

Select 3 options

  • A. array2 = array3;
  • B. array2 = array4;
  • C. array1 = array2;
  • D. array4 = array1;
  • E. array5 = array3


Correct Options are  : A B E

Note

There is a subtle difference between: int[] i; and int i[].

If you declare multiple variables in the same statement such as: int[] i, j; and int i[], j;, j is not of the same type in the two cases.

In the first case, j is an array of integers while in the second case, j is just an integer.

In this question: array1 is an array of int array2, array3, array4, and array5 are arrays of int arrays

Option 1, 2 and 5 are valid.




PreviousNext

Related