Analyze the following code:
```
public class Test {
public static void main(String[] args) {
int[] x = {1, 2, 3, 4, 5};
xMethod(x, 5);
}
public static void xMethod(int[] x, int length) {
System.out.print(" " + x[length - 1]);
xMethod(x, length - 1);
}
}
```
a. The program displays 1 2 3 4 6.
b. The program displays 1 2 3 4 5 and then raises an ArrayIndexOutOfBoundsException.
c. The program displays 5 4 3 2 1.
d. The program displays 5 4 3 2 1 and then raises an ArrayIndexOutOfBoundsException.
d. The program displays 5 4 3 2 1 and then raises an ArrayIndexOutOfBoundsException.
xMethod(x, 5) is invoked, then xMethod(x, 4), xMethod(x, 3), xMethod(x, 2), xMethod(x, 1), xMethod(x, 0). When invoking xMethod(x, 0), a runtime exception is raised because System.out.print(" "+x[0-1]) causes array out of bound.
You might also like to view...
A page layout technique that often uses a percentage value for width is called _____________.
a. fluid b. fixed c. hierarchical d. alignment
A gaseous system is designed to apply a liquid, usually water, to all areas in which a fire has been detected. _________________________
Answer the following statement true (T) or false (F)