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 use of ‘Return’ with an uppercase ‘R’ is incorrect; Java requires the lowercase keyword ‘return’.
B
There is no proper base case defined for termination.
C
The multiplication operation should be enclosed in parentheses.
D
The main method must return an integer value.
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | upadhgau000 | 2 | 2 | 0m 00s | 200 |
| #2 | imeanbusinessreplit | 1 | 1 | 0m 00s | 100 |
| #3 | singhris000 | 1 | 1 | 0m 29s | 71 |
| #4 | isaact.taylor52 | 1 | 1 | 1m 50s | -10 |
Items per page:
10
1 – 4 of 4
APFIVE