14.9k views
1 vote
"in program arrays12.java a swap method is called. does the swap method exchange parameter values x and y?"

User AveryLiu
by
5.9k points

1 Answer

5 votes

Yes the swap method exchange parameter values if passed by reference or the value gets changed inside the function.

Step-by-step explanation:

Since the program is not given, I will try to guide you about the mode of parameters.

The meaning of swap is interchanging the values. It can be done by using temporary variable or without using it (if the values are integers).

While passing the parameters, there are two ways, call by value/pass by value and call by reference/ pass by reference.

If call by value, then the value gets swapped only inside the function and will not reflected in the calling portion. Call by reference is other way round.

User Congbin Guo
by
4.6k points