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{publicinti=0;publicSuper(Stringtext){i=1;}}publicclassSubextendsSuper{publicSub(Stringtext){i=2;}publicstaticvoidmain(Stringargs[]){Subsub=newSub(Hello”);System.out.println(sub.i);}}Whatistheresult?()

A.0

B.1

C.2

D.Compilationfails.


相关考题:

classSuper{2.privateinta;3.protectedSuper(inta){this.a=a;}4.}.....11.classSubextendsSuper{12.publicSub(inta){super(a);}13.publicSub(){this.a=5;}14.}Whichtwo,independently,willallowSubtocompile?() A.Changeline2to:publicinta;B.Changeline2to:protectedinta;C.Changeline13to:publicSub(){this(5);}D.Changeline13to:publicSub(){super(5);}E.Changeline13to:publicSub(){super(a);}

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.

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{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;}

classsuper{publicfloatgetNum(){return3.0f;}}publicclassSubextendsSuper{}Whichmethod,placedatline6,willcauseacompilererror?() A.PublicfloatgetNum(){return4.0f;}B.PublicvoidgetNum(){}C.PublicvoidgetNum(doubled){}D.PublicdoublegetNum(floatd){retrun4.0f;}

对于下列代码,下列哪个叙述是正确的? class A { public int i=0; A(int m) { i = 1; } } public class B extends A { B(int m) { i = 2; } public static void main(String args[]){ B b = new B(100); System.out.println(b.i); //【代码】 } }A.程序提示编译错误。B.编译无错误,【代码】输出结果是0。C.编译无错误,【代码】输出结果是1。D.编译无错误,【代码】输出结果是2。