单选题在Java语言中,如果你有下面的类定义: abstract class Shape { abstract void draw(); } Class Square extends Shape {} 如果你试图编译上面的代码会发生()。A一切成功编译BShape可以编译,Square不能编译CSquare可以编译,Shape不能编译DShape,Square都不能编译
单选题
在Java语言中,如果你有下面的类定义: abstract class Shape { abstract void draw(); } Class Square extends Shape {} 如果你试图编译上面的代码会发生()。
A
一切成功编译
B
Shape可以编译,Square不能编译
C
Square可以编译,Shape不能编译
D
Shape,Square都不能编译
参考解析
解析:
暂无解析
相关考题:
在Java语言中,如果你有下面的类定义:abstractclassShape{abstractvoiddraw();}ClassSquareextendsShape{}如果你试图编译上面的代码会发生()。 A.一切成功编译B.Shape可以编译,Square不能编译C.Square可以编译,Shape不能编译D.Shape,Square都不能编译
下列程序片段中,能通过编译的是A.public abstract class Animal{ public void speak();}B.public abstract class Animal{ public void speak(){}}C.public class Animal{ public abstract void speak();}D.public abstract class Animal{ public abstract void speak(){}}
Given:10. interface Data { public void load(); }11. abstract class Info { public abstract void load(); }Which class correctly uses the Data interface and Info class?()() A.B.C.D.E.F.
如果有-个类MyFrame是Frame的子类,但它不能被实例化,请写出该类的声明头为( )。A.abstract class Frame. extends MyFrameB.abstract class MyFrame. extends FrameC.class MyFrame. abstract extends FrameD.class Frame. abstract extends MyFrame.
Java代码查错1.abstract class Name {private String name;public abstract boolean isStupidName(String name) {}}大侠们,这有何错误?
如果有一个类MyFrame是Frame的子类,但它不能被实例化,请写出该类的声明头为( )。A.abstract class Frame. extends MyFrameB.abstract class MyFrame. extends FrameC.class MyFrame. abstract extends FrameD.class Frame. abstract extends MyFrame.
下面的代码中有什么错误吗?_______using System;class A{public virtual void F(){Console.WriteLine("A.F");}}abstract class B:A{public abstract override void F();
下列程序片段中,能通过编译的是( )。 A.public abstract class Animal{ public void speak;}S 下列程序片段中,能通过编译的是( )。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{};}
编译以下代码,将出现什么情况?()abstract class Shape{ abstract void draw();}Class Square extends Shape{ }A. Square类和Shape类都可以成功编译B. Square类无法编译,但Shape类可以编译C. 类无法编译,但Square类可以编译D. Square类和Shape类都无法编译
指出下面哪一项是在抽象类中声明一个抽象方法。( )A.public abstract method();B.public abstract void method();C.public void abstract Method();D.public void method(){abstract;}
试题六(共15分)阅读以下说明、图和Java代码,填补Java代码中的空缺(1)~(6),将解答写在答题纸的对应栏内。【说明】已知对某几何图形绘制工具进行类建模的结果如图6.1所示,其中Shape为抽象(abstract)类,表示通用图形,Box(矩形)、Ellipse(椭圆)和Line(线条)继承(extends)了Shape类,其中,Circle表示圆(即特殊的椭圆)。下面的Java代码用于实现图 6-1所给出的设计思路,将其空缺处填充完整并编译运行,输出结果为:EllipseCircleEllipseCE【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; i2;++i) {drawAShap(shapes[i]);//绘制形状}}void close(){for (int i=0;i2; ++1) { []关闭图,删除所绘制图形(5) ;}}public static void main(String[] args){Diagram diagram= (6) ;diagram.drawShapes();diagram.close();}}
阅读以下说明和Java程序,填写程序中的空(1)~(6),将解答写入答题纸的对应栏内。【说明】以下Java代码实现一个简单绘图工具,绘制不同形状以及不同颜色的图形。部分接口、类及其关系如图5-1所示。【Java代码】interface?DrawCircle?{? //绘制圆形 public(1) ;}class?RedCircle?implements?DrawCircle?{? ?//绘制红色圆形???????public?void?drawCircle(int?radius,intx,?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,intradius,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();? ?}}
在Java语言中,如果你有下面的类定义: Abstract class Shape{ Abstract void draw(); } class Square extendeds Shape{} 如果你试图编译上面的代码会发生()。 A、一切成功编译B、Shape可以编译,Square不能编译C、Square可以编译,Shape不能编译D、Shape,Square都不能编译
在Java语言中,如果你有下面的类定义:abstractclassShape{ abstractvoiddraw();} ClassSquareextendsShape{} 如果你试图编译上面的代码会发生()。A、一切成功编译B、Shape可以编译,Square不能编译C、Square可以编译,Shape不能编译D、Shape,Square都不能编译
下列哪个类的声明是正确的()A、abstract final class HI{}B、abstract private move(){}C、protected private number;D、public abstract class Car{}
下列哪个类声明是正确的()。A、abstract final class H1{…}B、abstract private move(){…}C、protected private number;D、public abstract class Car{…}
下列是抽象类的声明的是()A、 abstract class figure{ }B、 class abstract figure{ }C、 seald class figure{ }D、 static class figure{ }
单选题在Java语言中,如果你有下面的类定义: abstract class Shape { abstract void draw(); } Class Square extends Shape {} 如果你试图编译上面的代码会发生()。A一切成功编译BShape可以编译,Square不能编译CSquare可以编译,Shape不能编译DShape,Square都不能编译
单选题现有: interface Data {public void load();} abstract class Info {public abstract void load();} 下列类定义中正确使用Data和Info的是哪项?()A public class Employee implements Info extends Data { public void load(){/*dosomething*/} }Bpublic class Employee extends Inf.implements Data{ public void load() {/*do something*/} }Cpublic class Empl.yee implements Inf extends Data{ public void Data.1oad(){* do something*/} public void load(){/*do something*/} }Dpublic class Employee extends Inf implements Data { public void Data.1oad() {/*do something*/) public void info.1oad(){/*do something*/} }
多选题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?()Apublic class Circle implements Shape { private int radius; }Bpublic abstract class Circle extends Shape { private int radius; }Cpublic class Circle extends Shape { private int radius; public void draw(); }Dpublic abstract class Circle implements Shape { private int radius; public void draw(); }Epublic class Circle extends Shape { private int radius;public void draw() {/* code here */} }Fpublic abstract class Circle implements Shape { private int radius;public void draw() { / code here */ } }
单选题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?()A Shape s = new Shape(); s.setAnchor(10,10); s.draw();B Circle c = new Shape(); c.setAnchor(10,10); c.draw();C Shape s = new Circle(); s.setAnchor(10,10); s.draw();D Shape s = new Circle(); s-setAnchor(10,10); s-draw();E Circle c = new Circle(); c.Shape.setAnchor(10,10); c.Shape.draw();
单选题在Java语言中,如果你有下面的类定义:abstractclassShape{ abstractvoiddraw();} ClassSquareextendsShape{} 如果你试图编译上面的代码会发生()。A一切成功编译BShape可以编译,Square不能编译CSquare可以编译,Shape不能编译DShape,Square都不能编译
单选题现有: 1. interface Animal { 2. void eat(); 3. } 4. 5. // insert code here 6. 7. public class HouseCat extends Feline { 8. public void eat() { } 9. } 和五个声明: abstract class Feline implements Animal { } abstract class Feline implements Animal { void eat(); } abstract class Feline implements Animal { public void eat(); } abstract class Feline implements Animal { public void eat() { } } abstract class Feline implements Animal { abstract public void eat(); } 分别插入到第5行,有几个可以通过编译?()A0B1C2D3
单选题现有: interface Animal { void eat () ; } //insert code here public class HouseCat extends Feline { public void eat() { } } 和五个申明 abstract class Feline implements Animal { } abstract class Feline implements Animal { void eat () ; } abstract class Feline implements Animal { public void eat();} abstract class Feline implements Animal { public void eat() {} } abstract class Feline implements Animal { abstract public void eat();} 结果为:()A1B2C3D4
单选题Java语言中常量的定义是哪项?()A public staticB public static finalC finalD public static abstract