Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
AP Computer Science A/Unit 6: Array
Start Practice TestPractice Test
About Exam
medium Solved by 2 students

Recursive Array Search

< Prev
Next >

What is printed when the following code 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

1

B

3

C

0

D

-1

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question
Mark for review

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Total Time
Score
#1deltasmpserver02 0m 00s -20
#2theofanusmischa01 1m 22s -92
#3bommasam00024 14m 14s -674
Items per page:
10
1 – 3 of 3
No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy|