资源描述:
《Java笔试试题集合》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、1JAVASE部分1、Choosethethreevalididentifiersfromthoselistedbelow.(Choosethree)?A.IDoLikeTheLongNameClassB.$byteC.constD._okE.3_case答:ABD2、Whichofthefollowinglinesofcodewillcompilewithouterror(Choosetwo)?A.inti=0;if(i){System.out.println(“Hi”);}B.booleanb
2、=true;booleanb2=true;if(b==b2){System.out.println(“Sotrue”);}C.inti=1;intj=2;if(i==1
3、
4、j==2)System.out.println(“OK”);D.inti=1;intj=2;if(i==1&
5、j==2)System.out.println(“OK”);答:BC3、Whichtwodemonstratea"hasa"relationship(Choosetwo)?A.publicinterfacePerson{
6、}publicclassEmployeeextendsPerson{}B.publicinterfaceShape{}publicinterfaceRectandleextendsShape{}C.publicinterfaceColorable{}publicclassShapeimplementsColorable{}D.publicclassSpecies{}CopyrightTarenaCorporation,2009.Allrightsreserved2publicclassAnimal
7、{privateSpeciesspecies;}E.interfaceComponent{}classContainerimplementsComponent{privateComponent[]children;}答:DE4、Whatwillhappenwhenyouattempttocompileandrunthefollowingcode?publicclassStatic{static{intx=5;}staticintx,y;publicstaticvoidmain(Stringargs
8、[]){x--;myMethod();System.out.println(x+y+++x);}publicstaticvoidmyMethod(){y=x+++++x;}}A.compiletimeerrorB.prints:1C.prints:2D.prints:3E.prints:7F.prints:8答:D5、Whatisthecorrectorderingfortheimport,classandpackagedeclarationswhenfoundinasinglefile?A.pa
9、ckage,import,classB.class,import,packageC.import,package,classD.package,class,import答:A6、Whatwillhappenwhenyouattempttocompileandrunthefollowingcode.publicclassPvf{staticbooleanPaddy;publicstaticvoidmain(Stringargv[]){System.out.println(Paddy);}}Copyr
10、ightTarenaCorporation,2009.Allrightsreserved3A.CompiletimeerrorB.compilationandoutputoffalseC.compilationandoutputoftrueD.compilationandoutputofnull答:B7、Giventhefolowingclasseswhichofthefollowingwillcompilewithouterror?interfaceIFace{}classCFaceimplem
11、entsIFace{}classBase{}publicclassObRefextendsBase{publicstaticvoidmain(Stringargv[]){ObRefob=newObRef();Baseb=newBase();Objecto1=newObject();IFaceo2=newCFace();}}A.o1=o2;B.b=ob;C.ob=b;D.o1=b;答:ABD8、下面那几个函数是publicvoidmethod(){...}的重载函数?A)public