Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
medium Solved by 2 students

Recursive Method Return Value

Mark
< Prev
Next >

Consider the following code segment. What value is returned by the method call tailSum(4, 0)?

public class Main {
    public static int tailSum(int n, int accumulator) {
        if(n == 0)
            return accumulator;
        return tailSum(n - 1, accumulator + n);
    }
    public static void main(String[] args) {
        System.out.println(tailSum(4, 0));
    }
}
A

4

B

7

C

10

D

8

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|