1.
Q26: What does the following code accomplish? Assume that
alpha is a correctly declared array with non-default values and that the variable target contains a value.
int place = -1;
int index = 0;
for (int x : alpha) {
if (x == target)
place = index;
index += 1;
}
placecontains the index of the first occurrence oftargetwithinalpha, -1 otherwise- Incorrect
placecontains the index of the last occurrence oftargetwithinalpha, -1 otherwise- Correct
placealways contains -1- Incorrect
- the code "finds"
targetwithinalpha - Incorrect
- the code does not work because you can’t get the index with an enhanced for loop
- Incorrect
