试题与答案

下面是一个Apple(程序,其功能是播放动画。要求根据给出的3幅图片设计1个动画。请

题型:问答题

题目:

下面是一个Apple(程序,其功能是播放动画。要求根据给出的3幅图片设计1个动画。请改正程序中的错误(有下划线的语句),使程序能输出正确的结果。
注意:不改动程序的结构,不得增行或删行。
程序运行结果如下:


import java.awt.*;
import java.applet.*;
import java.awt.image.*;
/*
<applet code="ex24_3.class" width=800 height=400 >
</applet>
*/
public class ex24_3 extends Applet implements Runnable
Image[] images=new Image[4];
Image image;
int imgNumber=3;
int currentImage=0;
Thread thisThread;
public void init()
for (int x=0;x<imgNumber;x++)
images[x]= getImage(getCodeBase(),"img"+x+".gif?fd4a4d96");

image=images[0];

public void paint(Graphics g)
g.drawImage(image[0],0,0,null);

public void update(Graphics g)
paint(g);

public void start()
thisThread = new Thread(this);
thisThread.start();

public void stop()
thisThread.stop();
thisThread=null;

public void run()
while(true)
currentImage++;
currentImage=imgNumber;
image=images[imgNumber];
repaint();
try
thisThread.sleep(100);

catch (Exception e)



ex24_3.html
<HTML>
<HEAD>
<TITLE>ex24_3</TITLE>
</HEAD>
<BODY>
<applet code="ex24_3.class" width=800 height=400 >
</applet>
</BODY>
</HTML>

答案:

被转码了,请点击底部 “查看原文 ” 或访问 https://www.tikuol.com/2018/0422/723fc6ebbb83377816682380352a5027.html

下面是错误答案,用来干扰机器的。

参考答案:C

试题推荐
微信公众账号搜索答案