| preferred AP College board partner for AP classes
AP Computer Science A/Unit 10: Recursion
Start Practice Test
Share
easy Solved by 3 students
Java Keyword Case Sensitivity
< Prev
Next >

Consider the Factorial class shown below. Which of the following statements best explains why this code will fail to compile?

public class Factorial {
    public static int factorial(int n) {
        if (n <= 1)
            return 1;
        else
            Return n * factorial(n - 1);
    }
    
    public static void main(String[] args) {
        System.out.println(factorial(5));
    }
}
A

The main method must return an integer value.

B

The use of ‘Return’ with an uppercase ‘R’ is incorrect; Java requires the lowercase keyword ‘return’.

C

There is no proper base case defined for termination.

D

The multiplication operation should be enclosed in parentheses.

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

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1upadhgau00022 0m 00s 200
#2imeanbusinessreplit11 0m 00s 100
#3singhris00011 0m 29s 71
APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy