试题八(15分,每空3分)
阅读以下说明和Java程序,将应填入__(n)__处的字句写在答题纸的对应栏内
【说明】
以下程序的功能时三角形、矩形和正方形的面积输出。
程序由5个类组成:areatest是主类,类Triangle,Rectangle和Square分别表示三角形、矩形和正方形,抽象类Figure提供了一个计算面积的抽象方法。
【程序】
public class areatest{
public static viod main(string args[]){
Figure[]Figures={
New Triangle(2,3,3),new rectangle(5,8),new square(5)
};
for (int i= 0;i< Figures.length;i++){
system.out.println(Figures+”area=”+ Figures.getarea());
}
}
}
public string tostring(){
return”rectangle: height=”+ height +”, width=”+ width +”:”;
}
public double getarea(){
return __(2)__
}
}
public class square exends __(3)__
{
public square(double width) {
__(4)__ ;
}
public string tostring(){
return” square:width=”+width”:”;
}
}
public class rectangle entend __(5)__
{
double la;
double lb;
double lc;
public triangle(double la ,double lb,double lc){
this.la=la; this.lb=lb; this.lc=lc;
}
public string tostring(){
return” triangle:sides=”+la+”, ”+lb+”, ”+lc+”:”;
}
public double get area(){
double s=(la+lb+lc)/2.0;
return math.sqrt(s*(s-la) *(s-lb) *(s-lc));
}
}: [NextPage]
答案
试题一
(1)i:1,1,8
(2)1→sw
(3) 0→BIT[i]
(4)NOP,或空操作
(5)1→BIT[i]
试题二
(1)j%2,及其等价形式
(2)i+=2,及其等价形式
(3)tag>2,或tag==3或tag>=3,及其等价形式
(4)9
(5)45
试题三
(1)p && k(2)!p->next,及其等价形式
(3)q->next
(4)prep->next
(5)q->next=p
试题四
(1)(h-9)*60+m,及其等价形式
(2)time + R[k].d[ch-'a']*20 其中ch-'a'可以表示为ch-97,R[k]可以表示为R[R[k].no]
(3)R[t].num == R[j].num && R[t].time > R[j].time,及其等价形式
(4)t!=i,及其等价形式,表达式的值为真也正确
(5)R[i],及其等价形式
试题五
(1)Asc("A")+i-1,或64+i,及其等价形式
(2)(h-9)*60+m,及其等价形式
(3)Combol.Text
(4)Value
(5)Time+R(k).d(m)*20 其中m可表示为Asc(ch)-Asc("A")或Asc(ch)-65,k可表示为R(R(k).no)
试题六 (C++)
(1)public Figure
(2)height*width
(3)public Rectangle
(4)this->height=this->width=width
(5)public Figure 若填public Rectangle只给1分
试题七
(1)False
(2)True
(3)SetFocus
(4)Delete
(5)Update
试题八 (Java)
(1)Figure
(2)height*width
(3)Rectangle
(4)super(width,width)
(5)Figure
| 广告合作:400-664-0084 全国热线:400-664-0084 Copyright 2010 - 2017 www.my8848.com 珠峰网 粤ICP备15066211号 珠峰网 版权所有 All Rights Reserved
|