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

Recursive Method Output

Mark
< Prev
Next >

What is printed when the following code segment is executed?

public class Test {
    public static void main(String[] args) {
        System.out.println(loop(3));
    }
    public static int loop(int n) {
        if(n == 0)
            return 0;
        return n + loop(n-1);
    }
}
A

6

B

3

C

7

D

Compilation Error

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

Question Leaderboard

Not enough data yet to show leaderboard.

AI Tutor

How can I help?

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