Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This code fragment uses arrays in Java. The first line declares and allocates an

ID: 3557904 • Letter: T

Question

This code fragment uses arrays in Java. The first line declares and allocates an array of two integers. The next two lines initialize it. (Java arrays are indexed starting from 0.)

Int[] A = new int[2];

A[0] = 0; A[1] = 2;

f(A[0], A[A[0]});

Function f is defined as:

Void f(int x, int y) {

x=1;

y=3;

}

For each of the following parameter-passing methods, say what the final values in the array A would be, after the call to f. (There may be more than one correct answer)

a. By value.

b. By reference.

c. By value-result.

d. By macro expansion.

e. By name.

Explanation / Answer

a. By value.

A = { 0 , 0 }

b. By reference.

A = { 1 . 3 }

c. By value-result.

A ={ 0 , 0 }

d. By macro expansion.

e. By name.