Find the error(s) in the following recursive method, and explain how to correct it (them). This method should find the sum of the values from 0 to n.
```
public int sum(int n) {
if (n == 0) {
return 0;
}
else {
return n + sum(n);
}
}
```
The code above will result in infinite recursion, unless the value initially passed to the method is 0 (the base case). There is no code to make the recursive call on line 6 sim- pler than the previous call. The call on line 6 should decrease n by 1.
You might also like to view...
What chart type can display two different chart types at the same time?
A) Multiple B) Mixed C) Combo D) Combination
The BIOS chip creates a link between the operating system and the hardware components. Over time, hardware components become obsolete and are upgraded to meet standards. Suppose a new hard drive is not recognized correctly. What could the end user perform to fix this problem?
a. Change operating systems. b. Contact the hard drive manufacturer. c. Upgrade (flash) the BIOS. d. Change the CMOS battery.