Question 1 of 10
A rink locker linear-searches a 1D array from index 0 for badge 6. What text does this Java code display?
int[] badges = {9, 6, 2, 6};
int target = 6;
int checks = 0;
int found = -1;
for (int i = 0; i < badges.length; i++) {
checks++;
if (badges[i] == target) {
found = i;
break;
}
}
System.out.print(found + " " + checks);
- A. 1 2
- B. 3 4
- C. 0 1
- D. 1 4