Consider the following program:
public class Main { public static void foo() { try {/* w w w . j a va2 s . c o m*/ throw new ArrayIndexOutOfBoundsException(); } catch(ArrayIndexOutOfBoundsException oob) { throw new Exception(oob); } } public static void main(String []args) { try { foo(); } catch(Exception re) { System.out.println(re.getCause()); } } }
Which one of the following options correctly describes the behavior of this program?
d.
the foo()
method catches ArrayIndexOutOfBoundsException and chains it to an Exception object.
however, since Exception is a checked exception, it must be declared in the throws clause of foo()
.