(7-1)Derived类是Base类的子类,下面()语句是错误的。
A. BaseObj=newDerived();
B. DerivedObj=newBase();
C. BaseObj=newBase();
DerivedObj=newDerived();
查看答案
(7-1)有如下程序,在①处添加()方法,编译时会产生错误。classGood{publicfloatgetNum(){return2.0f;}}publicclassBetterextendsGood{①}
A. publicfloatgetNum(){return4.0f;}
B. publicdoublegetNum(floatd){return3.0f;}
C. publicvoidgetNum(doubled){}
D. publicvoidgetNum(){}
(7-1)以下程序运行结果是()。classFatherX{publicIntegergetX(){returnnewInteger(10);}}classSonextendsFatherX{publicDoublegetX(){returnnewDouble(20);}}publicclassDemo12{publicstaticvoidmain(String[]args){FatherXf=newFatherX();Sons=newSon();System.out.println(f.getX()+s.getX());}}
A. 30
B. 30.0
C. 30.000
D. 编译失败
(7-1)以下程序的运行结果是()。classA{A(){System.out.print(10);}}publicclassDemoextendsA{publicstaticvoidmain(String[]args){newA();newDemo();}}
A. 10
B. 1010
C. 编译失败
D. 程序可以正常运行,但没有输出内容
(7-1)定义了如下的Father类和Derived类,则下面()语句是正确的。abstractclassFather{publicabstractvoidcall();}classDerivedextendsFather{publicvoidcall(){}}
A. FatherObj=newDerived();
B. DerivedObj=newFather();
C. FatherObj=newFather();
DerivedObj=newDerived();