单项选择题
现有:
1. class Propeller2 {
2. pulolic static void main (String[]args)//add code here?
3. { new Propeller2().topGo(); }
4.
5.void topGo() //add code here?
6. { middleGo(); }
7.
8.void middleGo() //add code here?
9. { go(); System.out.println ("late middle"); }
void go() //add code here?
12. {throw new Exception(); }
13. }
为使代码通过编译,需要在哪一行加入声明throws Exception?()
A.只在第11行
B.在第8行和第11行
C.在第5行、第8行和第11行
D.在第2行、第5行、第8行和第11行
点击查看答案&解析
相关考题
-
单项选择题
现有: class Parser extends Utils { public static void main (String[] args) { try{System.out.print (new Parser().getlnt("42")); } catch (Exception e) { System.out.println("Exc"); } } int getlnt (String arg) throws Exception { return Integer.parselnt (arg); } class Utils { int getlnt (String arg) {return 42; } } 结果为()
A. 42
B. Exc
C. 42Exc
D.编译失败 -
单项选择题
现有: class Parser extends Utilis { public static void main (String [] args) { try { System. out.print (new Parser ( ) .getlnt ("42")} ; } catch (NumberFormatException n) { System.out .println ( "NFExc" ) ; } } int getlnt (String arg) throws NumberFormatException{ return Integer.parselnt (arg) ; } class Utils { int getlnt (String arg) { return 42; } } 结果为 :()
A. NFExc
B. 42
C. 42NFExc
D.编译失败 -
单项选择题
现有: class Birds { public static void main (String [] args) { try { throw new Exception () ; } catch (Exception e) { try { throw new Exception () ; } catch (Exception e2) { System.out.print ("inner "); } System. out.print ( "middle" ) ; } System.out.print ("outer") ; } } 结果是()
A. inner outer
B. middle outer
C. inner middle outer
D..编译失败
