What is stored by a reference variable?What would be the results after the following code was executed? int[] array1 = {10, 20, 30, 40}; int [] array2 = {20, 30, 50, 60}; array1 = array2; array2 = array1;

Respuesta :

tonb

Answer:

Both array1 and array2 would be pointing to the array with {20,30,50,60}.

Explanation:

array1 and array2 are references (pointers) to the array.

array1 = array2; only makes the array1 variable point to the same destination as the array2 variable.

The next assignment array2 = array1; therefore doesn't change anything. array2 was already pointing to this location.