网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
Giventhefollowingcode,writealineofcode&ens
Giventhefollowingcode,writealineofcodethat,wheninsertedattheindicatedlocation,willmaketheoverridingmethodinExtensioninvoketheoverriddenmethodinclassBaseonthecurrentobject.
classBase{
publicvoidprint(){
System.out.println("base");
}
}
classExtentionextendsBase{
publicvoidprint(){
System.out.println("extension");
//insertlineofimplementationhere
}
}
publicclassQ294d{
publicstaticvoidmain(Stringargs[]){
Extentionext=newExtention();
ext.print();
}
}
Fillinasinglelineofimplementation.()
参考答案
更多 “ Giventhefollowingcode,writealineofcodebase);}}classExtentionextendsBase{publicvoidprint(){System.out.println(extension);//insertlineofimplementationhere}}publicclassQ294d{publicstaticvoidmain(Stringargs[]){Extentionext=newExtention();ext.print();}}Fillinasinglelineofimplementation.() ” 相关考题
考题
Giventhefollowingcode:1)classParent{2)privateStringname;3)publicParent(){}4)}5)publicclassChildextendsParent{6)privateStringdepartment;7)publicChild(){}8)publicStringgetValue(){returnname;}9)publicstaticvoidmain(Stringarg[]){10)Parentp=newParent();11)}12)}Whichlinewillcauseerror?()A.line3B.line6C.line7D.line8E.line10
考题
Giventhefollowingcode:publicclassPerson{intarr[]=newint[10];publicstaticvoidmain(Stringa[]){System.out.println(arr[1]);}}Whichstatementiscorrect?()
A.Whencompilationsomeerrorwilloccur.B.Itiscorrectwhencompilationbutwillcauseerrorwhenrunning.C.Theoutputiszero.D.Theoutputisnull.
考题
Giventhefollowingcode:publicclassPerson{staticintarr[]=newint[10];publicstaticvoidmain(Stringa[]){System.out.println(arr[1];)}}Whichstatementiscorrect?()
A.Whencompilationsomeerrorwilloccur.B.Itiscorrectwhencompilationbutwillcauseerrorwhenrunning.C.Theoutputiszero.D.Theoutputisnull.
考题
Giventhefollowingcode:1)publicvoidmodify(){2)inti,j,k;3)i=100;4)while(i0){5)j=i*2;6)System.out.println(Thevalueofjis+j);7)k=k+1;8)i--;9)}10)}Whichlinemightcauseanerrorduringcompilation?()A.line4B.line6C.line7D.line8
考题
Giventhefollowingcode:publicclassTest{voidprintValue(intm){do{System.out.println(Thevalueis+m);}while(--m10)}publicstaticvoidmain(Stringarg[]){inti=10;Testt=newTest();t.printValue(i);}}Whichwillbeoutput?()A.Thevalueis8B.Thevalueis9C.Thevalueis10D.Thevalueis11
考题
Giventhefollowingcode:if(x0){System.out.println(first);}elseif(x-3){System.out.println(second);}else{System.out.println(third);}Whichrangeofxvaluewouldprintthestringsecond?()A.x0B.x-3C.x=-3D.x=0x-3
考题
Giventhefollowingcode,whichmethoddeclarations,wheninsertedattheindicatedposition,willnotcausetheprogramtofailcompilation?()publicclassQdd1f{publiclongsum(longa,longb){returna+b;}//insertnewmethoddeclarationhere}A.publicintsum(inta,intb){returna+b;}B.publicintsum(longa,longb){return0;}C.abstractintsum();D.privatelongsum(longa,longb){returna+b;}E.publiclongsum(longa,intb){returna+b;}
考题
Giventhefollowingcode,whichstatementsconcerningtheobjectsreferencedthroughthemembervariablesi,jandkaretrue,giventhatanythreadmaycallthemethodsa,bandcatanytime?()classCounter{intv=0;synchronizedvoidinc(){v++;}synchronizedvoiddec(){v--;}}publicclassQ7ed5{Counteri;Counterj;Counterk;publicsynchronizedvoida(){i.inc();System.out.println(a);i.dec();}publicsynchronizedvoidb(){i.inc();j.inc();k.inc();System.out.println(b);i.dec();j.dec();k.dec();}publicvoidc(){k.inc();System.out.println(c);k.dec();}}
考题
Giventhefollowingcode,whichcodefragments,wheninsertedattheindicatedlocation,willsucceedinmakingtheprogramdisplayabuttonspanningthewholewindowarea?()importjava.awt.*;publicclassQ1e65{publicstaticvoidmain(Stringargs[]){Windowwin=newFrame();Buttonbut=newButton(button);//insertcodefragmentherewin.setSize(200,200);win.setVisible(true);}}A.win.setLayout(newBorderLayout());win.add(but);B.win.setLayout(newGridLayout(1,1));win.add(but);C.win.setLayout(newBorderLayout());win.add(but,BorderLayout.CENTER);D.win.add(but);E.win.setLayout(newFlowLayout());win.add(but);
热门标签
最新试卷