Recursive Method Termination
Under which condition does the method countDown terminate without issue?
Examine the recursive method countDown designed to print a countdown from the input number to zero by making recursive calls. Identify under what circumstance the countDown method will terminate without error.
public void countDown(int n) {
if (n >= 0) {
System.out.println(n);
countDown(n - 1);
}
}
Under which condition does the method countDown terminate without issue?
A
Only when the initial number is a non-negative integer
B
Only when the initial number is zero
C
Only when the initial number is a negative integer
D
For all integer inputs
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
APFIVE