• 2021-04-14 问题

    publicstaticvoidparse(Stringstr){try{floatf=Float.parseFloat(str);}catch(NumberFormatExceptionnfe){f=0;}finally{System.out.println(f);}}publicstaticvoidmain(String[]args){parse(”invalid”);}Whatistheresult?() A.0.0 B.Compilationfails. C.AParseExceptionisthrownbytheparsemethodatruntime. D.ANumberFormatExceptionisthrownbytheparsemethodatruntime.

    publicstaticvoidparse(Stringstr){try{floatf=Float.parseFloat(str);}catch(NumberFormatExceptionnfe){f=0;}finally{System.out.println(f);}}publicstaticvoidmain(String[]args){parse(”invalid”);}Whatistheresult?() A.0.0 B.Compilationfails. C.AParseExceptionisthrownbytheparsemethodatruntime. D.ANumberFormatExceptionisthrownbytheparsemethodatruntime.

  • 1