Which statement about the following application is correct?
package mypkg;//w w w .j a v a 2 s . co m import java.io.*; class Exception1 extends RuntimeException {} public class Main { public static void main(String[] argv) throws Exception { // w1 try { throw new IOException("Auto-pilot error"); } catch (Exception | Exception1 e) { // w2 throw e; } catch (Exception a) { // w3 throw a; } } }
B.
A multi-catch block cannot contain two exceptions in which one is a subclass of the other, since it is a redundant expression.
Since Exception1 is a subclass of RuntimeException and RuntimeException is a subclass of Exception, line w2 contains a compilation error, making Option B the correct answer.
The rest of the lines of code do not contain any compilation errors.