Consider the following methods:
public static double average (int nums[]) {
int sum = 0;
for (int i = 0; i < nums. length; i++) {
sum + = nums[i];
}
return (1.0 * sum) / nums. length;
} / / average
public static int[] mystery (String a[]) {
int temp [] = new int[a. length];
for (int i = 0; i < a. length; i++) {
temp[i] = a[i]. length ();
}
return temp;
} / / mystery
What is output by running the following?
String spelling[] = {"against", "forms", "belief", "government", "democratic", "movement", "understanding", "single", "followed", "scenario"};
System. out. println (average (mystery (spelling)));
1. 10
2. 8.5
3. 8.1
4. Error, you cannot average Strings.
5. 8