Sequential Search Method Output
What is the output when the program is executed?
public class SequentialSearch {
public static int search(int[] arr, int target) {
for (int i = 0; i < arr.length; i++) {
if (arr[i] == target)
return i;
}
return -1;
}
public static void main(String[] args) {
int[] nums = {7, 9, 11, 13, 15};
System.out.println(search(nums, 11) + search(nums, 8));
}
}
A
null
B
1
C
-1
D
2
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE