版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
上海德邦物流股份有限公司招聘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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年营口市西市区城管协管招聘笔试参考题库及答案解析
- 《JBT 9132-2022烧结铁磷软磁材料技术规范》专题研究报告
- 应急预案有什么规定和预案(3篇)
- 2026糖尿病护理患者就业指导课件
- 民办非企业幼儿园建设项目可行性研究报告
- 2026年四环素类试题及答案
- 2026年税务稽查试题及答案
- 净菜配送项目可行性研究报告
- MWORKS电力电子与电机系统建模与仿真 课件 第四章 基于MWORKS的电机系统仿真
- 2026糖尿病合并痛风饮食课件
- 宿舍夜间疏散演练脚本
- 2025年建安杯信息通信建设行业安全竞赛题库及答案
- 2026年北京市丰台区高三一模语文试题【含答案】
- 汽车涂装专业英语词汇课件
- 河北建投校招笔试题库
- 2025年职业技能鉴定考试(换流站值班员-高级技师)在线题库及答案
- 非车险承保培训课件
- 工程交付使用说明书
- 医疗器械生产部员工岗前培训课件
- 水下爆破作业方案设计
- 产品设计说课要点解析
评论
0/150
提交评论