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

Primitive Type Method Call Error

< Prev
Next >

Which of the following best explains why the ConditionError class shown below will fail to compile?

public class ConditionError {
    public static int countRecursively(int n) {
        if(n.equals(0))
            return 0;
        else
            return n + countRecursively(n - 1);
    }
    
    public static void main(String[] args) {
        System.out.println(countRecursively(5));
    }
}
A

The base case condition is logically flawed.

B

The method countRecursively should return a boolean value.

C

The arithmetic operator in the recursive call is misused.

D

The code incorrectly attempts to call the equals method on a primitive int, which is not allowed.

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

Question Leaderboard

Not enough data yet to show leaderboard.

No comments yet. Be the first to comment!

AI Tutor

How can I help?

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