河南成教 / Java程序设计
[简答题] 阅读下列程序,请写出该程序的输出结果。
import java.applet.*;import java.awt.*;
class Point{
int x,y;
Point(int xx,int yy){ x=xx;y=yy;}
Point(Point p){x=p.x;y=p.y; }
void m(int dx,int dy){x+=dx;y+=dy;}
}
class Circle extends Point{
int r;
Circle(Point p, int rr){ super(p); r=rr; }
float c(){ return 3.14f*2.0f*r; }
float a(){ return 3.14f*r*r;}
}
public class sample extends Applet{
Circle yuan; Point d;
public void init() {d=new Point(2,5);yuan=new Circle(d,10);}
public void paint(Graphics g){
g.drawString("yuan Circle"+(int)(yuan.c()*100.0)/100.0,5,20);
g.drawString("yuan Area"+(int)(yuan.a()*100.0)/100.0,5,40);
}
}
import java.applet.*;import java.awt.*;
class Point{
int x,y;
Point(int xx,int yy){ x=xx;y=yy;}
Point(Point p){x=p.x;y=p.y; }
void m(int dx,int dy){x+=dx;y+=dy;}
}
class Circle extends Point{
int r;
Circle(Point p, int rr){ super(p); r=rr; }
float c(){ return 3.14f*2.0f*r; }
float a(){ return 3.14f*r*r;}
}
public class sample extends Applet{
Circle yuan; Point d;
public void init() {d=new Point(2,5);yuan=new Circle(d,10);}
public void paint(Graphics g){
g.drawString("yuan Circle"+(int)(yuan.c()*100.0)/100.0,5,20);
g.drawString("yuan Area"+(int)(yuan.a()*100.0)/100.0,5,40);
}
}
参考答案:
佳题速递: