假设有下面代码:class E1 extends Exception{ }class E2 extends E1{ }class TestParent {public void fun(boolean f) throw E1 {}}public class Test extends TestParent{//Here}以下方法放在//Here的位置,而且编译能通过的是()。
A. public void fun(boolean f) throws E1{ }
B. public void fun(boolean f) { }
C. public void fun(boolean f) throws E2{ }
D. public void fun(boolean f) throws E1, E2{ }
E. public void fun(boolean f) throws Exception
(专升本)一个异常处理中 finally语句块只能有一个或者可以没有。
A. 对
B. 错
看程序写出运行结果:public class Small{public static void main( String[] args ){Small t = new Small( );int b = t. get( );System.out.println(b);}public int get( ){try{return 1;}finally{return 2;}}}
写出程序运行结果:public class Demo{public static void main(String[] args){String str = null;try{if( str.length( ) == 0){System.out.print("The");}System.out.print(" Cow");}catch (Exception e ){System.out.print(" and");System.exit( 0 );}finally{System.out.print(" Chicken");}System.out.print(" show");}}