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

Java Recursive Method Output

< Prev
Next >

Consider the following class. What is printed when the main method is executed?

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

16

B

14

C

7

D

9

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

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Total Time
Score
#1kaisuki11 0m 00s 100
#2songqiuhui201211 0m 03s 97
#3bommasam00023 2m 25s 45
#4raufyildirim9511 2m 30s -50
#5y.seong202712 3m 00s -90
Items per page:
10
1 – 5 of 5
No comments yet. Be the first to comment!

AI Tutor

How can I help?

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