Given:
public class Main { class MyClass implements Closeable { public void close() { throw new RuntimeException("a"); }/* w w w .j av a2 s .c o m*/ } public static void main(String[] args) { new Main().run(); } public void run() { try (MyClass l = new MyClass();) { throw new IOException(); } catch (Exception e) { throw new RuntimeException("c"); } } }
Which exceptions will the code throw?
D is correct.
While the exception caught by the catch block matches choice A, it is ignored by the catch block.
The catch block just throws RuntimeException c without any suppressed exceptions.