go to previous page   go to home page   go to next page

Answer:

Yes.


Picture of the Action

It looks as if there is a contradiction here:

Actually, there is no contradiction here. Remember that an array is an object. When an object is a parameter, the called method gets a reference to the object, not a copy of the object.

In the example, the zeroElt() method gets a reference to the array object. Since the parameter x refers to the array, the method may change the array by using x. The picture shows this.

This is call by value, because when the method call cng.zeroElt(value, 0) is executed, the parameter x of the method gets the value held in the variable value, which is a reference to the array.


QUESTION 7:

Since the method zeroElt() has a reference to the array, can it change individual array elements?