Analyze the following code:

```

public class Test {
public static void main(String[] args) {
int[] a = new int[4];
a[1] = 1;
a = new int[2];
System.out.println("a[1] is " + a[1]);
}
}
```
a. The program has a compile error because new int[2] is assigned to a.
b. The program has a runtime error because a[1] is not initialized.
c. The program displays a[1] is 0.
d. The program displays a[1] is 1.

c. The program displays a[1] is 0.
After executing the statement a = new int[2], a refers to int[2]. The default value for a[0] and a[1] is 0.

Computer Science & Information Technology

You might also like to view...

Books that are available in electronic digital format are called ________

Fill in the blank(s) with correct word

Computer Science & Information Technology

To have a designer-quality look to your presentation that includes coordinating colors, matching fonts, and effects, you would apply a(n) ________ to the presentation

Fill in the blank(s) with correct word

Computer Science & Information Technology