| 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 2 students
Recursive Array Traversal Output
< Prev
Next >

What is the exact output produced by executing the main method?

public class AlternatePrint {
    public static void printAlternate(int[] arr, int index) {
         if(index >= arr.length) return;
         System.out.print(arr[index] + " ");
         if(index + 1 < arr.length)
             System.out.print(arr[index + 1] + " ");
         printAlternate(arr, index + 2);
    }
    public static void main(String[] args) {
         int[] data = {10, 20, 30, 40, 50};
         printAlternate(data, 0);
    }
}
A

10 20 30 40

B

10 30 50

C

10 20 30 40 50

D

20 40

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

Question Leaderboard

Not enough data yet to show leaderboard.

AI Tutor

How can I help?

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