| preferred AP College board partner for AP classes
AP Computer Science A/Unit 1: Primitive Types
Start Practice TestPractice Test
About Exam
medium Solved by 43 students
Recursive Method Output
< Prev
Next >

What is printed when the following code is executed?

public class WeirdCalc {
    public static int calc(int n) {
        if(n == 1)
            return 2;
        return calc(n - 1) * 2 + 1;
    }
    public static void main(String[] args) {
        System.out.println(calc(4));
    }
}
A

24

B

23

C

21

D

22

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

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1sgarv251322 0m 00s 200
#2sailajavadlamani3325 0m 00s 170
#3varunrajaram111 0m 00s 100
#4waynechen011011 0m 00s 100
#5l.alzahrani0411 0m 00s 100
#6leftoverjluck11 0m 26s 74
#7adedokuntaiye00611 0m 32s 68
#8demosolasis111 0m 52s 48
#9alchemax04311 1m 06s 34
#10y.seong202711 1m 45s -5
Items per page:
10
1 – 10 of 31
No comments yet. Be the first to comment!

AI Tutor

How can I help?

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