单项选择题
现有:
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..编译失败 -
多项选择题
现有: class Flow { public static void main(String [] args) try { System. out .print ("before") ; doRiskyThing ( ) ; System.out.print ("after ") ; } catch (Exception fe) { System.out.print ("catch") ; } System. out .println ( " done") ; } public static void doRiskyThing() throws Exception{ // this code returns unless it throws an Exception }} 可能会产生哪两项结果 ?()
A. before catch
B. before after done
C. before catch done
D. before after catch -
多项选择题
现有 1. class Calc { 2. public static void main(String [] args) { 3. try { 4. int x = Integer.parselnt ("42a") ; 5. //insert code here 6. System.out.print ("oops"); 7. } 8. } 9. } 下面哪两行分别插入到第五行,会导致输 "oops" ? ()
A. } catch (IllegalArgumentException e) {
B. } catch (IllegalStateException c) {
C. } catch (NumbelFormatException n) {
D. } catch (ClassCastException c) {
