程序读入用户输入的一个值,要求创建一个自定义的异常,如果输入值大于10,使用throw语句显式地引发异常,异常输出信息为“something’s wrong!”, 语句为()。     A、if ( i  10 )   throw Exception(“something’s wrong!”);B、if ( i  10 )   throw Exception e (“something’s wrong!”);C、if ( i  10 )   throw new Exception(“something’s

题目

程序读入用户输入的一个值,要求创建一个自定义的异常,如果输入值大于10,使用throw语句显式地引发异常,异常输出信息为“something’s wrong!”, 语句为()。     

  • A、if ( i > 10 )   throw Exception(“something’s wrong!”);
  • B、if ( i > 10 )   throw Exception e (“something’s wrong!”);
  • C、if ( i > 10 )   throw new Exception(“something’s wrong!”);
  • D、if ( i > 10 )  throw new Exception e ("something’s wrong!");
如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

程序读入用户输入的一个值,要求创建一个自定义的异常,如果输入值大于10,使用throw语句显式地引发异常,异常输出信息为“something’swrong!”,语句为()。

A.if(i>10)throwException(“something’swrong!”);

B.if(i>10)throwExceptione(“something’swrong!”);

C.if(i>10)thrownewException(“something’swrong!”);

D.if(i>10)thrownewExceptione("something’swrong!");


参考答案:C

第2题:

一Shall we do something?

一Let's go to see a film.

A. Right

B. Wrong


参考答案A

第3题:

There is something wrong with my TV set, I must have it ().

A.checking

B.check

C.to check

D.checked


参考答案:D

第4题:

下面程序输出的结果是什么? ( ) public class Quiz2 { public static void main(String args[]) { try {throw new MyException(); }catch(Exception e) { System.out.println("It's caught!"); }finally{ System.out.println("It's finally caught!"); } } } class MyExeeption extends Exception{}

A.It's finally caught!

B.It's caught!

C.It's caught!/It'sfinally caught!

D.无输出


正确答案:C
解析:本题是对异常处理基本知识的考查。本程序中创建了一个异常类MyExce-ption,它的祖先类是Exception。在程序中,程序先发出异常MyException,下面是catch捕获异常,但是catch列表中并没有与之对应的MyException,但是有一个Exception,它是MyException的祖先类。如果有多种异常需要捕获,在安排catch语句的顺序时要注意,应该首先捕获最特殊的类,然后逐渐一般化。例如,IOException类是FileNotFoundException类的父类,就应该首先捕获FileNotFoundException异常,然后捕获IOException异常。所以运行结果是Ifscaught!/It'sfinallycaught!

第5题:

下面程序输出的结果是什么? ( ) public class Quiz2 { public static void main(String args[]) { try {throw new MyException(); }catch(Exception e) { System.out.println("It's caught!"); }finally{ System.out.println("It's finally caught!"); } } } class MyException extends Exception{}

A.It's finally caught!

B.It's caught!

C.It's caught!/It's finally caught!

D.无输出


正确答案:C
解析:本题是对异常处理基本知识的考查。本程序中创建了一个异常类MyException,它的祖先类是Exception。在程序中,程序先发出异常MyException,下面是catch捕获异常,但是catch列表中并没有与之对应的MyExcepfion,但是有一个Exception,它是MyException的祖先类。如果有多种异常需要捕获,在安排catch语句的顺序时要注意,应该首先捕获最特殊的类,然后逐渐一般化。例如,IOExcepfion类是FileNotFoundException类的父类;就应该首先捕获FileNotFoundException异常,然后捕获IOExcepfion异常。所以运行结果是It'scaught!/It'sfinallycaught!

第6题:

-Your request for compensation made me surprised. What happened -()

A、It’s true.

B、It’s because of the quality.

C、There must be something wrong.


参考答案:B

第7题:

Something' s gone wrong with the window; it_______ not shut.

A、will

B、shall

C、would

D、should


正确答案:C

第8题:

程序读入用户输入的一个值,要求创建一个异常,如果输入值大于10,使用throw语句显示地引发异常,异常输出的信息为“something?swrong!”,语句为()

A.if(i>10)throwException(“something?swrong!”);

B.if(i>10)throwExceptione(“something?swrong!”);

C.if(i>10)thrownewException(“something?swrong!”);

D.if(i>10)thrownewExceptione(“something?swrong!”);


参考答案:C

第9题:

Java程序中读入用户输入的一个值,要求创建一个自定义的异常,如果输入值大于10,使用throw语句显式地引发异常,异常输出信息为“something’swrong!”,语句为()。

A.if(I>10)throw Exception(“something’swrong!”);

B.if(I>10)throw Exceptione(“something’swrong!”);

C.if(I>10)thrownew Exception(“something’swrong!”);

D.if(I>10)thrownew Exceptione(“something’swrong!”);


正确答案:C

第10题:

2号舱口处的起货机出故障了。()

  • A、There is something wrong with the derrick at hatch No.2.
  • B、There is something wrong with the derrick at hatch No.1.
  • C、There is something wrong with the winch at hatch No.2.
  • D、There is something wrong with the winch at hatch No.1.

正确答案:C

更多相关问题