题目内容 (请给出正确答案)
给出如下代码段: try { int x = Integer.parseInt("two"); } 下列哪个可以作为catch的异常?
[单选题]

给出如下代码段: try { int x = Integer.parseInt("two"); } 下列哪个可以作为catch的异常?

A.ClassCastException

B.IllegalStateException

C.NumberFormatException

D.ExceptionInInitializerError

提问人:网友肖和成 发布时间:2022-01-07
参考答案
查看官方参考答案
如搜索结果不匹配,请 联系老师 获取答案
网友答案
查看全部
  • · 有3位网友选择 D,占比30%
  • · 有3位网友选择 B,占比30%
  • · 有2位网友选择 C,占比20%
  • · 有2位网友选择 A,占比20%
匿名网友 选择了B
[194.***.***.176] 1天前
匿名网友 选择了B
[136.***.***.201] 1天前
匿名网友 选择了A
[209.***.***.63] 1天前
匿名网友 选择了C
[53.***.***.11] 1天前
匿名网友 选择了B
[10.***.***.129] 1天前
匿名网友 选择了C
[2.***.***.67] 1天前
匿名网友 选择了D
[64.***.***.135] 1天前
匿名网友 选择了D
[154.***.***.216] 1天前
匿名网友 选择了A
[232.***.***.41] 1天前
匿名网友 选择了D
[203.***.***.247] 1天前
加载更多
提交我的答案
登录提交答案,可赢取奖励机会。
更多“给出如下代码段: try { int x = Integer…”相关的问题
第1题
Given import java.io.*; class Main{ public void f1() throws ArithmeticException{} public void f2() throws FileNotFoundException{} public static void main(){ new Main().f1(); //line1 new Main().f2(); //line2 } } Which is correct?

A、No error in compilation

B、error at //line1 in compilation

C、error at //line2 in compilation

D、two errors at //line1 and //line2 in compilation

点击查看答案
第2题
关于异常的描述中,错误的是()。

A、异常是一种经过修正后程序仍可执行的错误。

B、异常是一种程序在运行中出现的不可恢复执行的错误。

C、不仅Java语言有异常处理,C++语言也有异常处理。

D、出现异常不是简单结束程序,而是执行某种处理异常的代码,设法恢复程序的执行。

点击查看答案
第3题

下列程序的执行,说法错误的是 (C) public class MultiCatch { public static void main(String args[]) { try { int a=args.length; int b=42/a; int c[]={1}; c[42]=99; System.out.println(“b=”+b); } catch(ArithmeticException e) { System.out.println( “除 0 异常: ” +e); } catch(ArrayIndexOutOfBoundsException e) { System.out.println( “数组超越边界异常: ” +e); } } } A 、程序将输出第 15 行的异常信息 下列程序的执行,说法错误的是: public class MultiCatch { public static void main(String args[]) { try { int a=args.length; int b=42/a; int c[]={1}; c[42] = 99; System.out.println(“b=”+b); } catch(ArithmeticException e) { System.out.println(“除0异常:”+e);} catch(ArrayIndexOutOfBoundsException e) { System.out.println(“数组超越边界异常:”+e); } } }

A、程序输出b=12

B、程序将输出第15和18行的异常信息

C、程序将输出第15行的异常信息

D、程序第10行出错

点击查看答案
第4题
给出下列代码: class Plane { static String s = "-"; public static void main(String[] args){ new Plane().s1(); System.out.println(s); } void s1() { try {s2();}catch (Exception e){  s += "c";  } } void s2() throws Exception { s3();  s += "2"; s3(); s += "2b"; } void s3() throws Exception{ throw new Exception(); } } 结果是什么?

A、-

B、-c

C、-c2

D、-2c

点击查看答案
第5题
Given import java.io.*; class Main{ public void f1() throws ArithmeticException{} public void f2() throws FileNotFoundException{} public static void main(){ new Main().f1(); //line1 new Main().f2(); //line2 } } Which is correct?

A、No error in compilation

B、error at //line1 in compilation

C、error at //line2 in compilation

D、two errors at //line1 and //line2 in compilation

点击查看答案
第6题
class Emu{ static String s = "-"; public static void main(String[] args){ try{ throw new Exception(); }catch(Exception e){ try{ try{ throw new Exception(); }catch (Exception ex){ s += "ic "; } throw new Exception(); } catch(Exception x){ s += "mc "; } finally{ s += "mf "; } }finally{ s += "of "; } System.out.println(s); } } What is the result?

A、-ic mf of

B、-ic mc mf of

C、-ic mc of mf

D、Compilation fails

点击查看答案
第7题
Given: import java.io.*; class Master { String doFileStuff() throws FileNotFoundException {  return "a";  } } class Slave extends Master { public static void main(String[] args){ String s = null; try {  s = new Slave().doFileStuff(); }catch ( Exception x){ s = "b";  } System.out.println(s); } // insert code here } Which, inserted independently at // insert code here, will compile, and produce the output b? (Choose all that apply.)

A、String doFileStuff() { return "b"; }

B、String doFileStuff() throws IOException { return "b"; }

C、String doFileStuff(int x) throws IOException { return "b"; }

D、String doFileStuff() throws Exception { return "b"; }

点击查看答案
第8题
读取以下的a.txt,统计相同单词的次数,最后按照次数的大小降序排列,输出到b.txt中。 a.txt (===算分隔符,不算单词,不考虑单词大小写) ============== hello world hello java world hello ============== b.txt ============ hello,3 world,2 java,1 ============ 提示:需要用到的内容有文本文件读和写操作。还要加上数据结构,有ArrayList, HashMap,Comparable等。
点击查看答案
第9题
Given: class Mineral{ } class Gem extends Mineral{ } class Miner{ static int x = 7; static String s = null; public static void getWeight(Mineral m){ int y = 0 / x; System.out.print(s + " "); } public static void main(String[] args){ Mineral[] ma = {new Mineral(), new Gem()}; for(Object o : ma) getWeight((Mineral) o); } } And the command-line invocation: java Miner What is the result?

A、null

B、null null

C、A ClassCastException is thrown.

D、A NullPointerException is thrown.

点击查看答案
第10题
假如你的薪酬支付有两种选择:(1)3年内每年末支付年薪5万元;(2)第3年末一次性支付。若银行存款年利率为4%。问:什么情况下,你会选择第一种薪酬支付方式?
点击查看答案
账号:
你好,尊敬的用户
复制账号
发送账号至手机
密码将被重置
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改
欢迎分享答案

为鼓励登录用户提交答案,简答题每个月将会抽取一批参与作答的用户给予奖励,具体奖励活动请关注官方微信公众号:简答题

简答题官方微信公众号

警告:系统检测到您的账号存在安全风险

为了保护您的账号安全,请在“简答题”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!

微信搜一搜
简答题
点击打开微信
警告:系统检测到您的账号存在安全风险
抱歉,您的账号因涉嫌违反简答题购买须知被冻结。您可在“简答题”微信公众号中的“官网服务”-“账号解封申请”申请解封,或联系客服
微信搜一搜
简答题
点击打开微信