Java: Array Quiz 2
Name __________________________________
Assume the following:
int[] a = {25, -3, 6, 0, -3, 6};
int[] b = new int[100];
int[] c = null;
For all questions write "exception" if the code would produce a runtime exception
(eg, NullPointerException or ArrayIndexOutOfBoundsException).
- _____________ Value of
a.length
?
- _____________ Value of
b.length
?
- _____________ Value of
c.length
?
- _____________ Value of
a[10]
?
- _____________ Value of
b[10]
?
- _____________ Value of
c[10]
?
- _____________ How many objects were created by the declarations?
- _____________ Value of n after
c = b;
b = a;
int n = b.length;
b = c;
- _____________ Value of n after
c = a;
int n = c[1];
- _____________ Value of n after
int n;
c = a;
a = null;
n = c[2];