| preferred AP College board partner for AP classes
AP Computer Science A/Unit 6: Array
Start Practice TestPractice Test
Share
About Exam
medium Solved by 7 students
Recursive Array Search
< Prev
Next >

What is printed when the program is executed?

public class FirstIndex {
    public static int findFirstIndex(int[] arr, int index, int target) {
         if(index == arr.length) return -1;
         if(arr[index] == target) return index;
         return findFirstIndex(arr, index + 1, target);
    }
    public static void main(String[] args) {
         int[] arr = {5, 7, 9, 7, 3};
         System.out.println(findFirstIndex(arr, 0, 7));
    }
}
A

0

B

-1

C

1

D

3

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1deltasmpserver02 0m 00s -20
#2theofanusmischa01 1m 22s -92
#3bommasam00024 14m 14s -674
Items per page:
10
1 – 3 of 3

AI Tutor

How can I help?

APFIVE © 2020.
Email: [email protected]|Privacy Policy