Skip to main content

Java Topic Practice

Array Search

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

For practice use only.

Array Search MCQ Practice

Array Search Java practice with 15 questions, code tracing, and a worked explanation for every answer.

Question 1 of 15

Answered 0 of 15

Choose one answer.

Code Tracing 01 - Array Search: track the final printed value.

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