Java Topic Practice
Linear and Binary Search
Practice mode with 15 Java-focused questions, immediate answer checks, and explanations.
For practice use only.
Linear and Binary Search MCQ Practice
Linear and Binary 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 - Linear and Binary Search: track the final printed value.
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);