AP CSA Unit-Level MCQ

Code Tracing: Sorting and Efficiency

Practice mode with 50 Java-focused questions, immediate answer checks, and explanations.

For practice use only.

Code Tracing: Sorting and Efficiency MCQ Practice

Code Tracing: Sorting and Efficiency AP Computer Science A topic practice with 50 original Java MCQs and immediate explanations.

Question 1 of 50

Answered 0 of 50

Choose one answer.

What is printed by this Sorting and Efficiency code trace?

int[] data = {4, 9, 2, 7, 5, 1};
int target = 7;
int index = -1;
for (int i = 0; i < data.length; i++) {
  if (data[i] == target && index == -1) index = i;
}
System.out.print(index);