JAVA程序员笔试题目与答案

上传人:人*** 文档编号:497975358 上传时间:2023-02-25 格式:DOC 页数:8 大小:76KB
返回 下载 相关 举报
JAVA程序员笔试题目与答案_第1页
第1页 / 共8页
JAVA程序员笔试题目与答案_第2页
第2页 / 共8页
JAVA程序员笔试题目与答案_第3页
第3页 / 共8页
JAVA程序员笔试题目与答案_第4页
第4页 / 共8页
JAVA程序员笔试题目与答案_第5页
第5页 / 共8页
点击查看更多>>
资源描述

《JAVA程序员笔试题目与答案》由会员分享,可在线阅读,更多相关《JAVA程序员笔试题目与答案(8页珍藏版)》请在金锄头文库上搜索。

1、1. Given:Integeri=newInteger(42);Longl=newLong(42);Doubled=newDouble(42.0);WhichtwoexpressionsevaluatetoTrue?A. (i=1)B. (i=d)C. (d=1)D. (i.equals(l)E. (d.equals(l)F. (i.equals(42)G. noneofaboveAnswer:2. Given:publicclassFoopublicstaticvoidmain(Stringargs)StringBuffera=newStringBuffer(A);StringBuffer

2、b=newStringBuffer(B);operate(a,b);System.out.println(a+,+b);staticvoidoperate(StringBufferx,StringBuffery)x.append(y);y=x;Whatistheresult?A. Thecodecompilesandprints“A,B”.B. Thecodecompilesandprints“A,A”.C. Thecodecompilesandprints“B,B”.D. Thecodecompilesandprints“AB,B”.E. Thecodecompilesandprints“A

3、B,AB”.F. Thecodedoesnotcompilebecause“+”cannotbeoverloadedforStringBuffer.Answer:3. Given:classBaseClassprivatefloatx=1.0f;protectedfloatgetVar()returnx;classSubclassextendsBaseClassprivatefloatx=2.0f;/inserthereWhichtwoarevalidexamplesofmethodoverriding?A. floatgetVar()returnx;B. publicfloatgetVar(

4、)returnx;C. publicdoublegetVar()returnx;D. protectedfloatgetVar()returnx;E. publicfloatgetVar(floatf)returnf;Answer:4. WhichofthefollowingaremethodsoftheRunnableinterfaceA) runB) startC) yieldD) stopAnswer:5. Whichofthefollowingarelegalstatements?A) floatf=1/3;B) inti=1/3;C) floatf=1.01;D) doubled=9

5、99d;Answer:6. Given:publicclasstest(publicstaticvoidmain(stringargs)Stringfoo=args1;Stringbaz=args2;Stringbax=args3;Andthecommandlineinvocation:JavaTestredgreenblueWhatistheresult?A. bazhasthevalueof“”B. bazhasthevalueofnullC. bazhasthevalueof“red”D. bazhasthevalueof“blue”E. baxhasthevalueof“green”F

6、. thecodedoesnotcompileG. theprogramthrowsanexceptionAnswer:7. Whichofthefollowingstatementsaretrue?A) ThegarbagecollectionalgorithminJavaisvendorimplementedB) ThesizeofprimitivesisplatformdependentC) Thedefaulttypeforanumericalliteralwithdecimalcomponentisafloat.D) YoucanmodifythevalueinanInstanceo

7、ftheIntegerclasswiththesetValuemethodAnswer:8. Given:inti=1,j=10;doif(i+-j)continue;while(i5);Afterexecution,whatarethevaluesforiandj?A. i=6andj=5B. i=5andj=5C. i=6andj=4D. i=5andj=6E. i=6andj=6Answer:9. Given:importjava.io.IOException;publicclassExceptionTestpublicstaticvoidmain(Stringargs)trymetho

8、dA();catch(IOExceptione)System.out.println(CaughtIOException);catch(Exceptione)System.out.println(CaughtException);publicvoidmethodA()thrownewIOException();Whatistheresult?A. Thecodewillnotcompile.B. Theoutputis:caughtexception.C. Theoutputis:caughtIOException.D. Theprogramexecutesnormallywithoutpri

9、ntingamessage.Answer:10. Given:publicclassTestpublicstaticStringoutput=;publicstaticvoidfoo(inti)tryif(i=1)thrownewException();output+=1;catch(Exceptione)output+=2;return;finallyoutput+=3;output+=4;publicstaticvoidmain(Stringargs)foo(0);foo(1);/line24Whatisthevalueofthevariableoutputatline24?Answer:

10、11. Given:publicclassFooimplementsRunnable/line1publicvoidrun(Threadt)/line2System.out.println(Running.);publicstaticvoidmain(Stringargs)newThread(newFoo().start();Whatistheresult?A. AnexceptionisthrownB. TheprogramexistswithoutprintinganythingC. Anerroratline1causescompilationtofail.D. Anerroratlin

11、e2causesthecompilationtofail.E. “Running”isprintedandtheprogramexitsAnswer:12. Given:ClassOne.javapackagecom.abc.pkg1;publicclassClassOneprivatecharvar=a;chargetVar()returnvar;ClassTest.javapackagecom.abc.pkg2;importcom.abc.pkg1.ClassOne;publicclassClassTestextendsClassOnepublicstaticvoidmain(String

12、args)chara=newClassOne().getVar();/line5charb=newClassTest().getVar();/line6Whatistheresult?A. Compilationwillfail.B. Compilationsucceedsandnoexceptionsarethrown.C. Compilationsucceedsbutanexceptionisthrownatline5inClassTest.java.D. Compilationsucceedsbutanexceptionisthrownatline6inClassTest.java.An

13、swer:13. Whichisavalididentifier?A. falseB. defaultC. _objectD. a-classAnswer:14Ifyourunthecodebelow,whatgetsprintedout?Strings=newString(Bicycle);intiBegin=1;chariEnd=3;System.out.println(s.substring(iBegin,iEnd);A) BicB) icC) icyD) error:nomethodmatchingsubstring(int,char)Answer:15Whatwillhappenwh

14、enyouattempttocompileandrunthefollowingcodepublicclassMySwitchpublicstaticvoidmain(Stringargv)MySwitchms=newMySwitch();ms.amethod();publicvoidamethod()intk=10;switch(k)default:/Putthedefaultatthebottom,nothereSystem.out.println(Thisisthedefaultoutput);break;case10:System.out.println(ten);case20:System.out.println(twenty);break;A) NoneoftheseoptionsB) CompiletimeerrortargetofswitchmustbeanintegraltypeC) CompileandrunwithoutputThisisthedefaultoutputD) CompileandrunwithoutputofthesinglelinetenAnswer:第二部分:J2EE部份1简述J2EEArchitecture。2.简述JSP在WebContainer中的生命周期。3如何使用数据库连接池?有什么好处

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 解决方案

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号