本谜题测试的是你对某些规则的掌握程度,这些规则用于声明从方法中抛出并被catch语句块所捕获的异常。下面的三个程序每一个都会打印些什么?不要假设它们都可以通过编译: import java.io.IOException. public class Arcane1 { public static void main(String[] args) { try { System.out.println("Hello world"). } catch(IOException e) { System.out.println("I’ve never seen println fail!"). } } }
public class Arcane2 { public static void main(String[] args) { try { // If you have nothing nice to say, say nothing } catch(Exception e) { System.out.println("This can’t happen"). } } }
public class Arcane3 implements Type3 { public void f() { System.out.println("Hello world"). } public static void main(String[] args) { Type3 t3 = new Arcane3(). t3.f(). } }