欢迎来到天天文库
浏览记录
ID:39549761
大小:67.00 KB
页数:11页
时间:2019-07-06
《JAVA英文面试题》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、JAVA英文面试题满分:100分(考试时间:1个小时)一选择题(共20题,每题5分,共100分)lQuestion1Whatwillhappenwhenyouattempttocompileandrunthiscode?abstractclassBase{abstractpublicvoidmyfunc(){};publicvoidanother(){System.out.println("Anothermethod");}}publicclassAbsextendsBase{publicstaticvoidma
2、in(Stringargv[]){Baseb=newAbs();//Ab.myfunc();//B}publicvoidmyfunc(){System.out.println("MyFunc");}publicvoidamethod(){myfunc();}}[1choice]1)Thecodewillcompileandrun,printingoutthewords"MyFunc"2)Thecompilerwillcomplainerrorat//A.3)Thecompilerwillcomplainerror
3、at//B.4)Thecompilerwillcomplainerroratotherposition.lQuestion2Whatwillbetheoutputwhenthefollowingcodeiscompiledandrun(Assumingwritteninsidemain)?Strings1=newString("amit");System.out.println(s1.replace('m','r'));System.out.println(s1);Strings3="arit";Strings4
4、="arit";Strings2=s1.replace('m','r');System.out.println(s2==s3);System.out.println(s3==s4);[1choice]A.aritamitfalsetrueB.aritarittruetrueC.amitamitfalsefalseD.aritarittruefalselQuestion3Given:Whatwillhappenifyoucompile/runthefollowingcode?classMyClass{intx;My
5、Class(inti){x=i;}publicstaticvoidmain(Stringargs[]){MyClassm1=newMyClass(100);MyClassm2=newMyClass(100);System.out.println(m1==m2);if(m1.equals(m2)){System.out.println("Bothareequal");}else{System.out.println("Botharenotequal");}}}[1choice]A.Compilationerror:
6、equals()methodwasnotdefined.B.trueBothareequalC.falseBothareequal.D.trueBotharenotequal.E.falseBotharenotequallQuestion4Given:1.publicclassFoo{2.publicstaticvoidmain(String[]args){3.StringBuffera=newStringBuffer(“A”);4.StringBufferb=newStringBuffer(“B”);5.ope
7、rate(a,b);6.system.out.printIn(a+“,”+b);7.}8.staticvoidoperate(StringBufferx,StringBuffery){9.x.append(y);10.y=x;11.}12.}Whatistheresult?[1choice]A.Thecodecompilesandprints“A,B”.B.Thecodecompilesandprints“A,A”.C.Thecodecompilesandprints“B,B”.D.Thecodecompiles
8、andprints“AB,B”.E.Thecodecompilesandprints“AB,AB”.F.Thecodedoesnotcompilebecause“+”cannotbeoverloadedforStringBuffer.lQuestion51.publicclasstest{2.publicstaticvoidadd3(Integeri){3.intval=
此文档下载收益归作者所有