2018年11月软件设计师考试模拟题下午(一)之六
作者:mb64a2dd422e24f2023-12-26 01:00:13
备考咨询 刷题指导
添加专属学姐
2024上半年软考备考资料+考试大纲
下载
摘要:对于【软件设计师】软考考试而言,试题无疑是最重要的学习资料之一。在软考备考过程中,吃透试题、掌握试题所考知识点、熟悉试题的出题思路,对我们提升分数的效果是最明显的,通过对试题的反复练习,还可以查漏补缺。今天,给大家带来【2018年11月软件设计师考试模拟题下午(一)】部分试题的详解,一起来看看吧~1、阅读以下说明和Java程序,填写程序中的空(1)~(6),将解答写入答
摘要:对于【软件设计师】软考考试而言,试题无疑是最重要的学习资料之一。在软考备考过程中,吃透试题、掌握试题所考知识点、熟悉试题的出题思路,对我们提升分数的效果是最明显的,通过对试题的反复练习,还可以查漏补缺。今天,给大家带来【2018年11月软件设计师考试模拟题下午(一)】部分试题的详解,一起来看看吧~
1、阅读以下说明和Java程序,填写程序中的空(1)~(6),将解答写入答题纸的对应栏内。【说明】以下Java代码实现一个简单绘图工具,绘制不同形状以及不同颜色的图形。部分接口、类及其关系如图5-1所示。【Java代码】interface DrawCircle { //绘制圆形
public (1) ;
}
class RedCircle implements DrawCircle { //绘制红色圆形
public void drawCircle(int radius,int
x, int y) {
System.out.println("Drawing Circle[red,radius:" + radius +
",x:" + x + ",y:" +y+ "]");
}
}
class GreenCircle implements DrawCircle { //绘制绿色圆形
public void drawCircle(int radius, int x,
int y) {
System.out.println("Drawing Circle[green,radius:" +radius+
",x: " +x+ ",y: " +y+ "]");
}
}
abstract class Shape { //形状
protected (2) ;
public Shape(DrawCircle drawCircle) {
this.drawCircle
= drawCircle;
}
public abstract void draw();
}
class Circle extends Shape { //圆形
private int x,y,radius;
public Circle(int x,int y,int
radius,DrawCircle drawCircle) {
(3) ;
this.x = x;
this.y = y;
this.radius =
radius;
}
public void draw() {
drawCircle.
(4) ;
}
}
public class DrawCircleMain {
public static void main(String[] args) {
Shape redCircle=new Circle( 100,100,10,
(5) );//绘制红色圆形
Shape greenCircle=new Circle(200,200,10,
(6) );//绘制绿色圆形
redCircle.draw();
greenCircle.draw();
}
}
答案:
答题解析:
1、阅读以下说明和Java程序,填写程序中的空(1)~(6),将解答写入答题纸的对应栏内。【说明】以下Java代码实现一个简单绘图工具,绘制不同形状以及不同颜色的图形。部分接口、类及其关系如图5-1所示。【Java代码】interface DrawCircle { //绘制圆形
public (1) ;
}
class RedCircle implements DrawCircle { //绘制红色圆形
public void drawCircle(int radius,int
x, int y) {
System.out.println("Drawing Circle[red,radius:" + radius +
",x:" + x + ",y:" +y+ "]");
}
}
class GreenCircle implements DrawCircle { //绘制绿色圆形
public void drawCircle(int radius, int x,
int y) {
System.out.println("Drawing Circle[green,radius:" +radius+
",x: " +x+ ",y: " +y+ "]");
}
}
abstract class Shape { //形状
protected (2) ;
public Shape(DrawCircle drawCircle) {
this.drawCircle
= drawCircle;
}
public abstract void draw();
}
class Circle extends Shape { //圆形
private int x,y,radius;
public Circle(int x,int y,int
radius,DrawCircle drawCircle) {
(3) ;
this.x = x;
this.y = y;
this.radius =
radius;
}
public void draw() {
drawCircle.
(4) ;
}
}
public class DrawCircleMain {
public static void main(String[] args) {
Shape redCircle=new Circle( 100,100,10,
(5) );//绘制红色圆形
Shape greenCircle=new Circle(200,200,10,
(6) );//绘制绿色圆形
redCircle.draw();
greenCircle.draw();
}
}
答案:
(5)(1)void drawCircle (int radius,int x,int y)
(2)DrawCircle drawCircle
(3)super.drawcircle=drawcircle
(4)drawCircle(radius,x,y)
(5)new RedCircle()
(6)new GreenCircle()
答题解析:
第一空是填接口里面的方法,在接口的实现里面找,可以发现应该填void drawCircle (int radius,int x,int y)。
第二空可以根据后面this drawCircle=drawCircle判断,这里应该有一个drawCircle属性,因此应该填)DrawCircle drawCircle。
第三空这里用super,用super. drawcircle来引用父类的成员。
第四空调用drawCircle(radius,x,y)方法。
第五、六空分别创建一个红色圆形对象和一个绿色圆形对象作为Circle里面的实参。
查看完整试题>>>
软考资料: 2024年软考论文范文> 软考考试核心重点难点汇总> 查看更多>
备考刷题:章节练习+每日一练> 软考历年试题+模拟题>查看更多>