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 1 students

Recursive Array Traversal Output

< Prev
Next >

Consider the following class. What is printed as a result of 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

20 40

C

10 20 30 40 50

D

10 30 50

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

Question Leaderboard

Not enough data yet to show leaderboard.

No comments yet. Be the first to comment!

AI Tutor

How can I help?

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