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
hard Solved by 2 students

Recursive Sum Calculation

Mark
< Prev
Next >

What is printed when the following program is executed?

public class RecursiveReturn {
    public static int recursiveSum(int n) {
        if(n <= 0) return 0;
        Thread t = new Thread(() -> {});
        t.start();
        try {
            t.join();
        } catch(InterruptedException e) {
            Thread.currentThread().interrupt();
        }
        return n + recursiveSum(n - 1);
    }
    
    public static void main(String[] args) {
        System.out.println(recursiveSum(3));
    }
}
A

6

B

3

C

Compilation Error

D

0

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|