问题 问答题

阅读下列程序,写出程序能。
import java. applet.*;
import java. awt. *;
public class C3602 extends,Applet implements Runnable

Thread myThread=null;
public void start()

setSize(300,200);
if(myThread==null)myThread=new Thread(this);
myThread. start();

public void run()

while(true)

trymyThread. sleep(500);
catch(InterruptedException e)
repaint();


public void paint(Graphics g)

double i=Math. random();
if(i<0.33)g.setColor(Color.yellow);
else if(i<0.66)g.setColor(Color. red);
else g.setColor(Color. blue);
int x=(int)(100*i);
g.fillOval(x,x,x,x);

答案

参考答案:程序功能:小应用程序在300*200大小的窗口里用随机产生的颜色(黄红蓝)、半径(0~100)和位置(0~100,0~100)每隔0.5秒重新涂一个圆块。

填空题
单项选择题