Upgrade to Java SE 8 OCP ( Java SE 6 and all prior versions) (1Z0-813)
© examsiri.com
Question : 8 of 8
Marks:
+1,
-0
Given the code fragment:
What is the result?
class MyResource1 implements Closeable {
public void close() {
System.out.print("r1 ");
}
}
class MyResource2 implements AutoCloseable {
public void close() throws IOException {
System.out.print("r2 ");
throw new IOException();
}
}
public class App2 {
public static void main(String[] args) {
try (MyResource1 r1 = new MyResource1();
MyResource2 r2 = new MyResource2();) {
System.out.print("try ");
} catch (Exception e) {
System.out.print("catch ");
for (Throwable t : e.getSuppressed()) {
System.out.println(t.getClass().getName());
}
}
}
}What is the result?
Go to Question: