问题 问答题


阅读以下说明和Java代码,将应填入(n)处的字句写在对应栏内。
【说明】
Java语言允许用户在需要时创建自己的异常类型,用于表达JDK中未涉及到的其他异常状况,这些异常必须继承Throwable类或其子类。用户自定义异常类通常属于Exception范畴,依据命名惯例,应以Exception结尾。用户自定义异常未被加入JRE(Java运行时环境)的控制逻辑中,因此永远不会自动抛出,只能由人工创建并抛出。
【Java程序】
class MyException (1) Exception{
private String id;
public MyException(String message,String id){
(2) ;//调用父类的构造函数
this. id=id;
}
Public String getId(){
return id;
}
}
public class Test{
public void testException()throws MyException{
throw (3) (“抛出自定义异常”,“123”);
}
public void catchException(){
tly{
testException();
} (4) (MyException e){
System.out.print(“捕获了如下异常:”);
e.printStackTrace();
}
}
public void static main(String args[]){
Test t=new Test();
t.catchException();
}
}
程序输出如下(补充完整):
捕获了如下异常: (5)
at Test.testException(...)

答案

参考答案:

解析:MyException:抛出自定义异常 e.printStaekTrace()能够打印异常堆栈,主要是异常发生位置信息。

单项选择题
阅读理解

阅读理解。

     Think about the last time you felt a negative emotion-like stress, anger, or frustration. What was going

through your mind as you were going through that negativity (消极)? Was your mind cluttered with (充

斥) different kinds of thoughts? Or was it paralyzed, unable to think?

     The next time you find yourself in the middle of a very stressful time, or you feel angry or frustrated,

stop. Yes, that's right, stop. Whatever you're doing, stop and sit for one minute. While you're sitting

there, completely immerse yourself in the negative emotion.

     Allow that emotion to consume you. Allow yourself one minute to truly feel that emotion. Don't cheat

yourself here. Take the entire minute-but only one minute-to do nothing else but feel that emotion.

     When the minute is over, ask yourself, "Am I willing to keep holding on to this negative emotion as I

go through the rest of the day?"

     Once you've allowed yourself to be totally immersed in the emotion and really feel it, you will be

surprised to find that the emotion clears rather quickly.

     If you feel you need to hold on to the emotion for a little longer, that is OK. Allow yourself another

minute to feel the emotion.

     When you feel you've had enough of the emotion, ask yourself if you're willing to carry that negativity

with you for the rest of the day. If not, take a deep breath. As you exhale, release all that negativity with

your breath.

     This exercise seems simple-almost too simple. But, it is very effective. By allowing that negative

emotion the space to be truly felt, you are dealing with the emotion rather than stuffing it down and trying

not to feel it. You are actually taking away the power of the emotion by giving it the space and attention it

needs. When you immerse yourself in the emotion, and realize that it is only emotion, it loses its control.

You can clear your head and proceed with your task.

1. Which one does not belong to the negative emotion?

A. anxiety

B. confusion

C. depression

D. sorrow

2. What should you do when you are into negativity according to the article?

A. Listen to some music.

B. Ignore it and do something else.

C. Just do nothing and truly feel that emotion.

D. Think about it and try to deal with it immediately.

3. The underlined word "immerse" (Paragraph 2) most probably means _____.

A. break down

B. get rid of

C. cut off

D. throw into

4. What's the best title of this text?

A. Clear Your Mental Space.

B. Deep Breath, Trouble Away.

C. Try to Avoid the Negative Emotion.

D. Keep Holding on to This Negative Emotion as Long as Possible.

5. The author's opinion towards negative emotion is _____.

A. doubtful

B. optimistic

C. frightened

D. confused