您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 招聘面试 > Java笔试试题集合
1CopyrightTarenaCorporation,2009.AllrightsreservedJAVASE部分1、Choosethethreevalididentifiersfromthoselistedbelow.(Choosethree)?A.IDoLikeTheLongNameClassB.$byteC.constD._okE.3_case答:ABD2、Whichofthefollowinglinesofcodewillcompilewithouterror(Choosetwo)?A.inti=0;if(i){System.out.println(“Hi”);}B.booleanb=true;booleanb2=true;if(b==b2){System.out.println(“Sotrue”);}C.inti=1;intj=2;if(i==1||j==2)System.out.println(“OK”);D.inti=1;intj=2;if(i==1&|j==2)System.out.println(“OK”);答:BC3、Whichtwodemonstrateahasarelationship(Choosetwo)?A.publicinterfacePerson{}publicclassEmployeeextendsPerson{}B.publicinterfaceShape{}publicinterfaceRectandleextendsShape{}C.publicinterfaceColorable{}publicclassShapeimplementsColorable{}D.publicclassSpecies{}2CopyrightTarenaCorporation,2009.AllrightsreservedpublicclassAnimal{privateSpeciesspecies;}E.interfaceComponent{}classContainerimplementsComponent{privateComponent[]children;}答:DE4、Whatwillhappenwhenyouattempttocompileandrunthefollowingcode?publicclassStatic{static{intx=5;}staticintx,y;publicstaticvoidmain(Stringargs[]){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.package,import,classB.class,import,packageC.import,package,classD.package,class,import答:A6、Whatwillhappenwhenyouattempttocompileandrunthefollowingcode.publicclassPvf{staticbooleanPaddy;publicstaticvoidmain(Stringargv[]){System.out.println(Paddy);}}3CopyrightTarenaCorporation,2009.AllrightsreservedA.CompiletimeerrorB.compilationandoutputoffalseC.compilationandoutputoftrueD.compilationandoutputofnull答:B7、Giventhefolowingclasseswhichofthefollowingwillcompilewithouterror?interfaceIFace{}classCFaceimplementsIFace{}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)publicvoidmethod(intm){...}B)publicintmethod(){...}C)publicvoidmethod2(){...}D)publicintmethod(intm,floatf){...}答:AD9、给出如下声明:Strings=“Example”;合法的代码有哪些?A)s=3B)s[3]=“X”C)inti=s.length()D)s=s+10答:CD10、如下哪些不是java的关键字?A)constB)NULLC)falseD)thisE)native答:B11、关于垃圾收集的哪些叙述是对的A)程序开发者必须自己创建一个线程进行内存释放的工作B)垃圾收集将检查并释放不在使用的内存C)垃圾收集允许程序开发者明确指定并立即释放该内存D)垃圾收集能够在期望的时间释放被java对象使用的内存答:B12、已知表达式intm[]={0,1,2,3,4,5,6};下面哪个表达式的值与数组下标量总数相等?A)m.length()B)m.lengthC)m.length()+1D)m.length-14CopyrightTarenaCorporation,2009.Allrightsreserved答:D13、方法resume()负责恢复哪些线程的执行A)通过调用stop()方法而停止的线程。B)通过调用sleep()方法而停止的线程。C)通过调用wait()方法而停止的线程。D)通过调用suspend()方法而停止的线程。答:D14、有关线程的哪些叙述是对的A)一旦一个线程被创建,它就立即开始运行。B)使用start()方法可以使一个线程成为可运行的,但是它不一定立即开始运行。C)当一个线程因为抢先机制而停止运行,它被放在可运行队列的前面。D)一个线程可能因为不同的原因停止并进入可运行状态。答:BCD15、已知如下代码:publicclassTest{longa[]=newlong[10];publicstaticvoidmain(Stringarg[]){System.out.print(a[6]);}}请问哪个语句是正确的?A)Outputisnull.B)Outputis0C)Whencompile,someerrorwilloccur.D)Whenrunning,someerrorwilloccur.答:C16、已知如下代码:publicclassTest{publicstaticvoidmain(Stringarg[]){inti=5;do{System.out.print(i);}while(--i5);System.out.print(“finished”);}}执行后的输出是什么?A)5B)4C)6D)finished5CopyrightTarenaCorporation,2009.Allrightsreserved答:AD17、已知如下代码:switch(m){case0:System.out.print(“Condition0”);case1:System.out.print(“Condition1”);case2:System.out.print(“Condition2”);case3:System.out.print(“Condition3”);default:System.out.print(“OtherCondition”);}当m的值为什么时能输出“Condition2”A)0B)1C)2D)3E)4F)None答:ABC18、下面的哪些声明是合法的?A)long1=4990B)inti=4LC)floatf=1.1D)doubled=34.4答:AD19、给出如下代码:classTest{privateintm;publicstaticvoidfun(){//somecode„}}如何使成员变量m被函数fun()直接访问?A)将privateintm改为protectedintmB)将privateintm改为publicintmC)将privateintm改为staticintmD)将privateintm改为intm答:C20、以下哪个方法用于定义线程的执行体?A)start()B)init()C)run()D)main()E)synchronized()答:C21、请看如下代码classPerson{privateinta;publicintchange(intm){returnm;}}publicclassTeacherextendsPerson{publicintb;6CopyrightTarenaCorporation,2009.Allrightsreservedpublicstaticvoidmain(Stringarg[]){Personp=newPerson();Teachert=newTeacher();inti;//pointx}}下面哪些放在//pointx?行是正确的?Ai=m;Bi=b;Ci=p.a;Di=p.change(30);Ei=t.b;答:DE22、给出下面的代码段:()publicclassBase{intw,x,y,z;publicBase(inta,intb){x=a;y=b;}publicBase(inta,intb,intc,intd){//assignmentx=a,y=bw=d;z=c;}}在代码说明//assignmentx=a,y=b处写下如下哪几个代码是正确的?A)Base(a,b);B)x=a,y=b;C)x=a;y=b;D)this(a,b);答:CD23、给出下面代码:publicclassPerson{staticintarr[]=newint[10];publicstaticvoidmain(Stringa[]){System.out.println(arr[1]);}}哪个选项是正确的?A.编译时将产生错误;B.编译时正确,运行时将产生错误;C.输出0;D.输出空。答:C24、关于运算符和描述正确的是7CopyrightTarenaCorporation,2009.AllrightsreservedA.执行移动B.执行翻转C.执行有符号右移,执行无符号右移D.执行无符号右移,执行有符号右移答:C25、下列关于栈的叙述正确的是A栈是非线性结构B栈是一种树状结构C栈具有先进先出的特征D栈具有后进先出的特征答:D26、选出Java语言中的关键词(多选)A.NULLB.sizeofC.implementsD.extends答:CD27、现有下述代码,选择出能够打印出”Test2”的数字(多选)switch(x){case1:System.out.println(Test1);case2:case3:System.out.println(Test2);break;}System.out.println(Test3);A.0D.3B.1E.4C.2答:CD28、字符(char)的整型表示范围为A.0...32767C.-256...255B.0...
本文标题:Java笔试试题集合
链接地址:https://www.777doc.com/doc-5197816 .html