Recursive Method Termination
Consider the following recursive method.
public void countDown(int n) {
if (n >= 0) {
System.out.println(n);
countDown(n - 1);
}
}
Under which condition will the countDown method terminate without causing an error?
A
For all integer inputs
B
Only when the initial number is zero
C
Only when the initial number is a non-negative integer
D
Only when the initial number is a negative integer
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | singhris000 | 1 | 1 | 0m 07s | 93 |
| #2 | upadhgau000 | 0 | 2 | 0m 00s | -20 |
| #3 | ethan | 0 | 2 | 0m 00s | -20 |
Items per page:
10
1 – 3 of 3
