Java Keyword Case Sensitivity
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.
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | upadhgau000 | 2 | 2 | 0m 00s | 200 |
| #2 | imeanbusinessreplit | 1 | 1 | 0m 00s | 100 |
| #3 | singhris000 | 1 | 1 | 0m 29s | 71 |
APFIVE