阅读以下程序class Test{static void F(){try{G();}Catch(Exception e){Console.Write(e.Message);e = new Exception(“F”);throw;}}static void G(){throw new Exception(“G”);}static void Main(){try{F();}catch(Exception e){Console.Write (e.Message);}}}以上程序运行的结果是()
A: F F
B: F G
C: G G
D: G F
A: F F
B: F G
C: G G
D: G F
举一反三
- 智慧职教: 现有: 1. class Birds { 2. public static void main (String [] args) { 3. try { 4. throw new Exception () ; 5. } catch (Exception e) { 6. try { 7. throw new Exception () ; 8. } catch (Exceptio
- 下列代码输出为( ): class Father{ public void F() { Console.Write("A.F"); } public virtual void G() { Console.Write("A.G"); } } class Son: Father{ new public void F() { Console.Write("B.F"); } public override void G() { Console.Write("B.G"); } } class override_new{ static void Main() { Son b = new Son(); Father a = b; a.F(); b.F(); a.G(); b.G(); } }
- 检查下面的代码: class E1 extends Exception{} class E2 extends E1{} public class Quiz6_l{ public static void f(boolean flag) throws E1,E2{ if(flag) { throw new E1(); } else { throw new E2(); } } public static void main(String[] args) { try{ f(true); } catch(E2 e2) { System.out.println("Caught E2"); }catch(E1 e1) { System.out.println("Caught El"); } } } 对上面的程序进行编译、运行,下面的叙述哪个是正确的:
- 下列哪些定义在接口中的方法是合法的? A: static void A() { System.out.println("A"); } B: final static void B(); C: void C() { } D: private void D(); E: public abstract void E(); F: static void F(); G: void G();
- 下面程序的执行结果是( )。public class Test {public static void main(String[] args) {new Test().test();}public void test(){try{System.out.print("try");}catch(ArrayIndexOutOfBoundsException e){System.out.print("catch1");}catch(Exception e){System.out.print("catch2");}finally{System.out.println("finally");}}} A: try finally B: try catch1 finally C: try catch2 finally D: finally