问题 单项选择题

当Applet程序中的init()方法为下列代码时,运行后用户界面会出现什么样的情况。
public void init()

setLayout(new BorderLayout());
add("North", new TextField(10));
add("Center", new Button("help"));

下面各选项中描述正确的是( )。

A.文本框将会出现在Applet的顶上,且有10个字符的宽度

B.按钮将会出现在Applet的正中间,且尺寸为正好能够包容help的大小

C.文本框将会出现在Applet的顶上,从最左边一直延伸到最右边;按钮将会出现在Applet的正中央,覆盖除文本框外的所有空间

D.按钮与文本框的布局依赖于Applet的尺寸

答案

参考答案:C

解析: 该题考查对容器布局策略的理解。边界布局管理器BorderLayout将容器按上北下南左西右东划分为东、南、西、北、中5部分,分别用英文单词East,South,North,West, Center来表示。其中,东、西、南、北4个方向的组件宽度为恰好能够包容组件的内容,而长度为延伸到该容器边界的长度;而对于中间的组件,它会扩充到除四边以外的整个容器区域。本题的具体情况是:文本框将会出现在 applet的顶上,长度为整个applet的宽度:按钮将会出现在applet的正中央,覆盖除文本框外的所有空间。

阅读理解

阅读理解。

     Long, long ago there was a very foolish thief. Do you know what he did one day? When he wanted to

steal(偷) the bell on his neighbour's door, he walked up to the door, took hold of (抓住) the bell and pulled

hard. The bell made a very loud noise. The thief was afraid and went home.

     Then he sat down to think, "I must do something about the noise," he said. He thought and thought. At

last he had an idea. "Ah, I'll put some cotton in my ears. Then I won't be able to hear the noise." The next

day he went to the door of his neighbour, and took hold of the bell. This time he pulled even harder. The

bell rang loudly, but the thief did not hear anything. With another hard pull he got the bell out. Just then the

neighbour came running out."Steal my bell? I'll teach you a lesson (教训), "the angry man shouted. And he

hit the thief on the nose.

     The foolish thief did not know how the neighbour found out he was stealing the bell. "Why did he come

out just then?" he wondered (感到疑惑).

1. The thief was trying to get _____.

A. his neighbour

B. his neighbour's doorbell

C. some cotton

D. a door with a bell on it

2. The thief put some cotton in his ears. He thought it would be _____ for him to steal the doorbell.

A. safe

B. difficult

C. dangerous

D. easy

3. The neighbour ran out probably (很可能) because _____.

A. he knew his doorbell was being stolen

B. he thought someone was eager (渴望的) to visit him

C. He realized (意识到) something strange happened

D. Both B and C

4. The neighbour hit the thief to _____.

A. give him lessons

B. punish (惩罚) him for stealing

C. help him with the bell

D. be his teacher

5. Which of the following is TRUE?

A. The thief understood why he was hit on the nose.

B. The thief knew why the neighbour came out.

C.The thief thought the neighbour could not hear the bell.

D. The thief didn't want to know why the neighbour ran out just at the time he stole the doorbell.

问答题 简答题