Pass as argument - a copy of the reference to the instantiated array is passed to the method. This means that any changes made to the array elements inside the method are persistent. The one exception to this is if you assign the argument to reference a different array in memory.
Q20: Put the following code in order to create a program that will declare and instantiate an array of 10 random values between 1 and 100 and then find the maximum value in the array.
import java.util.*;
public class main{
public static void main (String[] args) {
---
Random r = new Random();
int [] arr = new int[10];
---
for (int i = 0; i < 10; i++) {
arr[i] = r.nextInt(100) + 1;
System.out.println("arr["+i+"] is " + arr[i]);
}
---
int max = arr[0];
---
for (int i = 1; i < 10; i++) {
---
if (arr[i] > max)
---
max = arr[i];
---
}
---
System.out.println("Maximum value is " + max);
---
}
}