一切成功编译
Shape可以编译,Square不能编译
Square可以编译,Shape不能编译
Shape,Square都不能编译
第1题:
下列程序片段中,能通过编译的是( )。
A.public abstract class Animal{ public void speak;}
B.public abstract class Animal{ public void speak{);}
C.public class Animal{ pubilc abstract void speak;}
D.public abstract class Animal{ pubile abstract void speak{};}
第2题:
试题六(共15分)
阅读以下说明、图和Java代码,填补Java代码中的空缺(1)~(6),将解答写在答题纸的
对应栏内。
【说明】
已知对某几何图形绘制工具进行类建模的结果如图6.1所示,其中Shape为抽象(abstract)类,表示通用图形,Box(矩形)、Ellipse(椭圆)和Line(线条)继承(extends)了Shape类,其中,Circle表示圆(即特殊的椭圆)。
下面的Java代码用于实现图 6-1所给出的设计思路,将其空缺处填充完整并编译运行,输出结果为:
Ellipse
Circle
Ellipse
C
E
【Java代码】
(1) class Shape{
public Shape(String name){
this.name= name;
}
(2) void paint();
String getName(){
retum this.name;
}
final String name;
};
//Box 和Line类似下面 Ellipse,其代码略
class Ellipse (3) {
public Ellipse(String name){
super(name);
System.out.println("Ellipse");
}
Void paintO{∥绘制现状示意代码
System.out.println(getName0);
}
};
class Circle (4) {
public Circle(String name){
super(name);
System.out.println("Circle");
}
};
class Diagram{
private Shape shapes[]= new Shape[2];
public void drawAShape(Shape shape){
shape.paint();
}
void erase A Shape(Shape shape){
∥删除形状,代码略
}
void drawShapes(){
shapes*0+= new Circle("C”);
shapes[l]= new Ellipse("E");
for (int i=O; i<2;++i) {
drawAShap(shapes[i]);//绘制形状
}
}
void close(){
for (int i=0;i<2; ++1) { []关闭图,删除所绘制图形
(5) ;
}
}
public static void main(String[] args){
Diagram diagram= (6) ;
diagram.drawShapes();
diagram.close();
}
}
第3题:
在Java语言中,如果你有下面的类定义: Abstract class Shape{ Abstract void draw(); } class Square extendeds Shape{} 如果你试图编译上面的代码会发生()。
第4题:
在Java语言中,如果你有下面的类定义: abstract class Shape { abstract void draw(); } Class Square extends Shape {} 如果你试图编译上面的代码会发生()。
第5题:
public abstract class Shape { int x; int y; public abstract void draw(); public void setAnchor(int x, int y) { this.x = x; this.y = y; } } and a class Circle that extends and fully implements the Shape class. Which is correct?()
第6题:
编译代码classMySstringextendsString{}会出现的情况是()
第7题:
1. interface I { void go(); } 2. 3. abstract class A implements I { } 4. 5. class C extends A { 6. void go(){ } 7. } 结果是什么?()
第8题:
一切成功编译
Shape可以编译,Square不能编译
Square可以编译,Shape不能编译
Shape,Square都不能编译
第9题:
成功编译
不能编译,因为没有main方法
不能编译,因为String是abstract类型的
不能编译,因为String是final类型的
第10题:
代码通过编译
由于第1行的错误导致编译失败
由于笫3行的错误导致编译失败
由于第6行的错误导致编译失败
第11题:
一切成功编译
Shape可以编译,Square不能编译
Square可以编译,Shape不能编译
Shape,Square都不能编译
第12题:
不能通过编译
通过编译,输出为:A B
通过编译,输出为:B
通过编译,输出为:A
第13题:
编译以下代码,将出现什么情况?()
abstract class Shape
{ abstract void draw();}
Class Square extends Shape{ }
A. Square类和Shape类都可以成功编译
B. Square类无法编译,但Shape类可以编译
C. 类无法编译,但Square类可以编译
D. Square类和Shape类都无法编译
第14题:
此题为判断题(对,错)。
第15题:
在Java语言中,如果你有下面的类定义:abstractclassShape{ abstractvoiddraw();} ClassSquareextendsShape{} 如果你试图编译上面的代码会发生()。
第16题:
给定如下Java程序片断: class A{ public A (){ System.out.println("A"); } } class B extends A{ public B(){ System.out.println("B"); } public static void main(String[] args){ B b=new B(); } } 上述程序将()。
第17题:
现有: interface I { void go(); } abstract class A implements I { } class C extends A { void go(){ } } 结果是什么?()
第18题:
你编译代码classMySstringextendsString{}会出现的情况是()
第19题:
public abstract class Shape { private int x; private int y; public abstract void draw(); public void setAnchor(int x, int y) { this.x = x; this.y = y; } } Which two classes use the Shape class correctly?()
第20题:
一切成功编译
Shape可以编译,Square不能编译
Square可以编译,Shape不能编译
Shape,Square都不能编译
第21题:
代码通过编译
由于多个错误导致编译失败
由于第1行的错误导致编译失败
由于第6行的错误导致编译失败
第22题:
Shape s = new Shape(); s.setAnchor(10,10); s.draw();
Circle c = new Shape(); c.setAnchor(10,10); c.draw();
Shape s = new Circle(); s.setAnchor(10,10); s.draw();
Shape s = new Circle(); s->setAnchor(10,10); s->draw();
Circle c = new Circle(); c.Shape.setAnchor(10,10); c.Shape.draw();
第23题:
public class Circle implements Shape { private int radius; }
public abstract class Circle extends Shape { private int radius; }
public class Circle extends Shape { private int radius; public void draw(); }
public abstract class Circle implements Shape { private int radius; public void draw(); }
public class Circle extends Shape { private int radius;public void draw() {/* code here */} }
public abstract class Circle implements Shape { private int radius;public void draw() { / code here */ } }
第24题:
成功编译
不能编译,因为没有main方法
不能编译,因为String是abstract类型的
不能编译,因为String是final类型的