Answer
1. Passed by value
list[0] = 1 and list[1] = 3
2. Passed by reference
list[0] = 2 and list[1] = 6
3. Passed by value-effect
list[0] = 2 and list[1] = 6
Step-by-step explanation:
From the code segment above, the points to be noted are
1. An integer array list is declared
2. list is declared to accept only two integer values
3. list[0] = 1
4. list[1] = 3
For pass by value;
None of the actual arguments are changed, so the variables retain the values they were initialized with.
So,
list[0] = 1 and list[1] = 3
Passed by reference
With pass by reference, the arguments are changed.
Given that
list[0] = 1
list[1] = 3
The value of list[0] and list[1] are incremented by their respective original value, as follows
list[0] = 1 + 1 = 2
list[1] = 3 + 3 = 6
So, the new values becomes
list[0] = 2
list[1] = 6
3. Passed by value-effect
The passed by, value-result has the same effect as reference.