问题 填空题

请在代码中的画线处填写正确的语句 【16】 ,使程序输出hello world!。
//HelloApplet.java
Import java.awt.*;
Import java.applet.*;
Public class HelloApplet extends

Public void paint(Graphics g)

______ ("hello world!",20,20);

答案

参考答案:g.drawString

解析: 该程序是一个简单的 Applet程序,程序结构如下。
注释:用"//"起始的一行为注释行,在上面程序中,说明了文件名称,文件名称要与类名称一致。
import语句:装入java.awt和java.applet下所有的包,使得该程序可能使用这些包中所定义的类,它类似于C中的#include语句。类定义:声明一个公共类,用extends表示是Applet的子类。
方法重写:程序中重写父类Applet的paint()方法,其中参数g为Graphics类,它表明当前画的上下文。在paint()方法中,调用g的方法drawstring(),在坐标(20, 20)处输出字符串。其中的坐标是用像素点来表示的。该程序中没有出现main()方法,这是Applet与应用程序Application的区别之一。

阅读理解

阅读理解

       "Go for it!"

       The expression "Go for it!" is a way of encouraging someone to try something.

       "Go for it!" means you should not worry about failure or be too careful. You should take a chance

and be brave.

       "Go for it!" gets its name from football. But it is not the football played in most countries such as

England, France or Japan, but the kind of football played in the United States and Canada.

       One of the most exciting times in football comes when a team has failed, after three tries, to move

the ball forward ten yards. The team must make a very important decision.

       The conservative(保守的)choice is to kick the ball and accept temporary defeat (暂时失败)in

order to get a good position for your team the next time it gets the ball. The more exciting choice,

however, is to try a fourth and final time to get the remaining yards needed.

       People now are certain to shout their advice.  Some will shout,  "Kick the ball!"  But others will

encourage the team to take a chance. "Go for it!" they will shout loudly.

       In the 1980's, people began using this expression in many kinds of situations(情形) to encourage

someone to act bravely.

       There is no guarantee(保证) that the action you "Go for it!" will succeed. But when you decide to

go for it, you only consider your action. That is the chance you can take. You put your fears behind.

You choose courage over safety. You hold your breath and go for it.

1. What does "Go for it!" mean?   

A. You should go straight on.

B. You should take a chance and be brave.

C. You should go to school and ask teachers for help.

D. You should be very careful.

2. The expression"Go for it!" comes from _____________ football.

A. English        

B. French     

C. Japanese        

D. American

3. According to the passage, when we decide to go for it, we only consider _____________.

A. safety         

B. action        

C. result            

D. success

4. In which of the following situations should we use the expression"Go for it!" now?

A. We decide to avoid(逃避) trouble or danger for the future.

B. We try to improve our English for better education.  

C. We need to make a quick decision at the last moment                  

D. We have to make a choice between success and failure.

单项选择题