classsuper{publicfloatgetNum(){return3.0f;}}publicclassSubextendsSuper{}Whichmethod,placedatline6,willcauseacompilererror?() A.PublicfloatgetNum(){return4.0f;}B.PublicvoidgetNum(){}C.PublicvoidgetNum(doubled){}D.PublicdoublegetNum(floatd){retrun4.0f;}
classsuper{publicfloatgetNum(){return3.0f;}}publicclassSubextendsSuper{}Whichmethod,placedatline6,willcauseacompilererror?()
A.PublicfloatgetNum(){return4.0f;}
B.PublicvoidgetNum(){}
C.PublicvoidgetNum(doubled){}
D.PublicdoublegetNum(floatd){retrun4.0f;}
相关考题:
classsuper{publicintgetLength(){return4;}}publicclassSubextendsSuper{publiclonggetLength(){return5;}publicstaticvoidmain(String[]args){supersooper=newSuper();Subsub=newSub();System.out.printIn(sooper.getLength()+,”+sub.getLength()};}Whatistheoutput?()A.4,4B.4,5C.5,4D.5,5E.Thecodewillnotcompile.
classBaseClass{privatefloatx=1.0f;protectedvoidsetVar(floatf){x=f;}}classSubClassextendsBaseClass{privatefloatx=2.0f;//insertcodehere16.}Whichtwoarevalidexamplesofmethodoverriding?() A.VoidsetVar(floatf){x=f;}B.PublicvoidsetVar(intf){x=f;}C.PublicvoidsetVar(floatf){x=f;}D.PublicdoublesetVar(floatf){x=f;}E.PublicfinalvoidsetVar(floatf){x=f;}F.ProtectedfloatsetVar(){x=3.0f;return3.0f;}
classsuper(publicintI=0;publicsuper(stringtext)(I=1))publicclasssubextendssuper(publicsub(stringtext)(i=2)publicstaticvoidmain(straingargs[])(subsub=newsub(Hello”);system.out.PrintIn(sub.i);))Whatistheresult?()A.Compilationwillfail.B.Compilationwillsucceedandtheprogramwillprint“0”C.Compilationwillsucceedandtheprogramwillprint“1”D.Compilationwillsucceedandtheprogramwillprint“2”
classsuper{2.publicfloatgetNum(){return3.0f;}3.}4.5.publicclassSubextendsSuper{6.7.}Whichmethod,placedatline6,willcauseacompilererror?() A.PublicfloatgetNum(){return4.0f;}B.PublicvoidgetNum(){}C.PublicvoidgetNum(doubled){}D.PublicdoublegetNum(floatd){retrun4.0f;}
classSuper{publicinti=0;publicSuper(Stringtext){i=1;}}publicclassSubextendsSuper{publicSub(Stringtext){i=2;}publicstaticvoidmain(Stringargs[]){Subsub=newSub(Hello”);System.out.println(sub.i);}}Whatistheresult?()A.0B.1C.2D.Compilationfails.
classSuper{publicintgetLenght(){return4;}}publicclassSubextendsSuper{publiclonggetLenght(){return5;}publicstaticvoidmain(String[]args){Supersooper=newSuper();Subsub=newSub();System.out.println(sooper.getLenght()+“,”+sub.getLenght());}}Whatistheoutput?()A.4,4B.4,5C.5,4D.5,5E.Compilationfails.
classSuper{publicIntegergetLenght(){returnnewInteger(4);}}publicclassSubextendsSuper{publicLongGetLenght(){returnnewLong(5);}publicstaticvoidmain(String[]args){Supersooper=newSuper();Subsub=newSub();System.out.println(sooper.getLenght().toString()+,”+sub.getLenght().toString());}}Whatistheoutput?()A.4,4B.4,5C.5,4D.5,5E.Compilationfails.
classSuper{2.publicfloatgetNum(){return3.0f;}3.}4.5.publicclassSubextendsSuper{6.7.}Whichmethod,placedatline6,causescompilationtofail?() A.publicvoidgetNum(){}B.publicvoidgetNum(doubled){}C.publicfloatgetNum(){return4.0f;}D.publicdoublegetNum(floatd){return4.0d;}
将下列哪个代码(A,B,C,D)放入程序中标注的【代码】处将导致编译错误? class A { public float getNum() { return 3.0f; } } public class B extends A { 【代码】 }A.public float getNum(){return 4.0f;}B.public void getNum(){ }C.public void getNum(double d){ }D.public double getNum(float d){return 4.0d;}