上海德邦物流股份有限公司招聘java面试真题_第1页
上海德邦物流股份有限公司招聘java面试真题_第2页
上海德邦物流股份有限公司招聘java面试真题_第3页
上海德邦物流股份有限公司招聘java面试真题_第4页
上海德邦物流股份有限公司招聘java面试真题_第5页
已阅读5页,还剩4页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

上海德邦物流股份有限公司招聘java面试真题一、选择题(20)[含多选]。(请在正确的答案上打“J")Question1)Whichofthefollowingstatementsaretrue?Aninterface canonlycontainmethodand not variablesInterfacescannothaveconstructorsAclassmay extendonlyoneotherclass and implement onlyoneinterfaceInterfacesaretheJavaapproachtoaddressingitslackofmultipleinheritance,butrequireimplementingclassestocreatethefunctionalityoftheInterfaces.Question2)Which of thefollowingstatementsaretrue?The garbagecollectionalgorithminJava is vendorimplementedThe sizeofprimitivesisplatformdependentThe defaulttypeforanumericalliteral withdecimalcomponent is a float.You canmodifythevalueinanInstance of theIntegerclass with the setValuemethodQuestion3)Whichofthefollowingaretruestatements?I/O inJavacanonlybe performedusingthe Listener classesThe RandomAccessFileclass allowsyoutomove directly toany pointafile.ThecreationofanamedinstanceoftheFileclasscreatesamatchingfileintheunderlyingoperatingsystemonlywhentheclosemethodiscalled.ThecharacteristicsofaninstanceoftheFileclasssuchasthedirectoryseparator,dependonthecurrentunderlyingoperatingsystemQuestion4)WhatwillhappenwhenyouattempttocompileandrunthefollowingcodeclassBase{publicvoidBase(){System.out.println(“Base”);}}publicclassInextendsBase{publicstaticvoidmain(Stringargv[]){Ini=newIn();})CompiletimeerrorBaseisakeywordCompilationandnooutputatruntimeOutputofBaseRuntimeerrorBasehasnovalidconstructorQuestion5)Youhaveapublicclasscalledmyclasswiththemainmethoddefinedasfollowspublicstaticvoidmain(Stringparm[]){System.out.println(parm[0]);}IfyouattempttocompiletheclassandruntheprogramasfollowsjavamyclasshelloWhatwillhappen?Compiletimeerror,mainisnotcorrectlydefinedRuntimeerror,mainisnotcorrectlydefinedCompilationandoutputofjavaCompilationandoutputofhelloQuestion6)WhichofthefollowingstatementsareNOTtrue?Ifaclasshasanyabstractmethodsitmustbedeclaredabstractitself.Whenappliedtoa class,thefinalmodifiermeans it cannotbe sub-classedAllmethodsinan abstractclassmustbedeclared as abstracttransientandvolatileareJavamodifiersQuestion7)Whatwillhappenwhenyouattempttocompileandrunthefollowingclass?classBase{Base(inti){System.out.println(“Base”);))classSevernextendsBase{publicstaticvoidmain(Stringargv口){Severns=newSevern();)voidSevern(){System.out.println(“Severn”);))Compilationandoutputofthestring“Severn”atruntimeCompilation and nooutput atruntimeCompiletimeerrorCompilation and outputof thestring “Base”Question8)Whichofthefollowingstatementsaretrue?Static methods cannot be overridentobenon staticStatic methods cannot be declaredasprivatePrivatemethodscannotbeoverloadedAnoverloadedmethodcannotthrowexceptionsnotcheckedinthebaseclassQuestion9)Whichofthefollowingstatementsaretrue?TheautomaticgarbagecollectionoftheJVMpreventsprogramsfromeverrunningoutofmemoryAprogramcansuggestthatgarbagecollectionbeperformedbutnotforceitGarbagecollectionisplatformindependentAnobjectbecomeseligibleforgarbagecollectionwhenallreferencesdenotingitaresettonull.Question10)GiventhefollowingcodepublicclassSytch{intx=2000;publicstaticvoidmain(Stringargv口){System.out.println(“Ms”+argv[1]+“Pleasepay$”+x);))WhatwillhappenifyouattempttocompileandrunthiscodewiththecommandlinejavaSytchJonesDiggleCompilation and output ofMs Diggle Please pay $2000CompiletimeerrorCompilation and output ofMs Jones Please pay $2000Compilation but runtime errorQuestion11)Youneedtoreadinthelinesofalargetextfilecontainingtensofmegabytesofdata.WhichofthefollowingwouldbemostsuitableforreadinginsuchafilenewFileInputStream(“”)newInputStreamReader(newFileInputStream(“”))newBufferedReader(newInputStreamReader(newFileInputStream(“”)));newRandomAccessFileraf=newRandomAccessFile(“myfile.txt“,“+rw”);Question12)Whichofthefollowingstatementsaretrue?Constructors cannothavea visibilitymodifierConstructorsarenotinheritedConstructors canonlyhave aprimitivereturntypeConstructors canbemarked publicandprotected,but notprivateQuestion13)Whichstatementistrue?1)An anonymous inner class may be declared as final.2)An anonymous inner class can be declared as private.3)An anonymous inner class can implementmultipleinterfaces.4)An anonymous inner class can accessfinalvariablesinany enclosingscope.5)Constructionofaninstanceofastaticinnerclassrequiresaninstanceofheenclosingouterclass.Question14)publicclassFoo{publicstaticvoidmain(Stringsgf[]){StringBuffera=newStringBuffer(“A”);StringBufferb=newStringBuffer(“B”);operate(a,b);System.out.println(a+“,"+b);}staticvoidoperate(StringBufferx,StringBuffery){x.append(y);y=x;}}Whatistheresult?1)Thecodecompilesandprints“A.B”.2)Thecodecompilesandprints“A.A”.3)Thecodecompilesandprints“B.B”.4)Thecodecompilesandprints“AB.B”.5)Thecodecompilesandprints“AB.AB”.Question15)Whichofthefollowingthreadstatetransitionsarevalid?Fromreadytorunning.From running to ready.From running to waiting.From waiting to running.From waiting to ready.Fromreadytowaiting.Question16)Whatistheresultofattemptingtocompileandrunthefollowingprogram?publicclassTest{privateinti=j;privateintj=10;publicstaticvoidmain(Stringargs[]){System.out.println((newTest()).i);))Compiler error complaining about accessrestriction ofprivatevariablesofTest.Compiler error complaining about forwardreferencing.No error - The output is 0;No error - The output is 10;Question17)Whichtwocannotdirectlycauseathreadtostopexecuting?1)exitingfromasynchronizedblock2)callingthewaitmethodonanobject3)callingthenotifymethodonanobject4)callingareadmethodonanInputStreamobject5)callingthesetPrioritymethodonathreadobjectQuestion18)Whichofthefollowingarecorrect,ifyoucompilethefollowingcode?publicclassCloseWindowextendsFrameimplementsWindowListener{publicCloseWindow(){addWindowListener(this);//ThisislistenerregistrationsetSize(300,300);setVisible(true);}publicvoidwindowClosing(WindowEvente){System.exit(0);}publicstaticvoidmain(Stringargs口) {CloseWindowCW=newCloseWindow();}}CompiletimeerrorRuntimeerrorCodecompilesbutFramesdoesnotlistentoWindowEventsCompileandrunssuccessfullyQuestion19)Whichstatementsdescribeguaranteedbehaviorofthegarbagecollectionandfinalizationmechanisms?Objectsare deletedwhentheycan no longerbe accessedthrough anyreference.The finalize() method will eventuallybecalledoneveryobject.The finalize() method will neverbecalled more thanonce onan object.An objectwill notbegarbagecollectedas long asitis possible foranactivepartof theprogramtoaccess it througha reference.The garbagecollector will useamarkand sweep algorithm.Question20)Aclassdesignrequiresthatamembervariableshouldbeaccessibleonlybysamepackage,whichmodiferwordshouldbeused?protectedpublicnomodiferprivate二.简答题。(80)(请

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论