| preferred AP College board partner for AP classes
AP Computer Science A/Unit 5: Writing Classes
Start Practice TestPractice Test
About Exam
medium Solved by 6 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

9

C

7

D

14

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
#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