欢迎来到天天文库
浏览记录
ID:37622097
大小:130.69 KB
页数:83页
时间:2019-05-26
《计算机真题回忆》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、考题回忆Sreejith310-0251.publicstaticvoidmain(Stringargs[]){Booleana[]=newBoolean[4];intI=1;System.out.println(a[I]);}Whatwillbeprinted?CompilationErrorinLine2CompilationErrorinline4ExceptioninLine4WillprinttrueWillprintfalseWillprintnullAns:F2.publicstaticvo
2、idmain(Stringargs[]){Integerb=newInteger(10);Add(b);System.out.println(b.intvalue());}voidAdd(Integerb){intI=b.intvalue();I+=3;b=newInteger(I)}Whatwillbeprintedout?Willprint13Willprint10CompilationErrorinLine4?.implicitconversiontoIntegertoStringisnotposs
3、ibleCompilationErrorinline10youcan'treinitializeaWrapperclassExceptioninLine10Ans:bclasstext{publicstaticvoidmain(Stringargs[]){Stringa=args[1];Stringb=args[2];Stringc=args[3];}}ifyouwillexecutejavatextcatdogsheepwhatwillbethevalueofthe'c'?catdogsheepComp
4、ilationErrorExceptionwilloccurAns:E4.publicstaticvoidmain(Stringargs[]){Floatf=newFloat(4.2f);Floatc;Doubled=newDouble(4.2);floatfl=4.2f;c=f;}whichwillreturntrue?.Selectallf.equls(d)c==fc==dc.equls(f)Ans:B,D5.publicstaticvoidmain(Stringargs[]){Strings;Sys
5、tem.out.println("s="+s);}whatwillbeprintedout?CompilationErrorAnExceptionwilloccurWillprints=nullWillprints=Ans:A6.classsextendsThread{intj=0;publicvoidrun(){try{Thread.sleep(5000);}catch(Exceptione){}j=100;}publicstaticvoidmain(Stringargs[]){st1=news();t
6、1.start();System.out.println(t1.j);}}whatyouhavetodotoensurethat'j'willprint100youhavemaket1asDaemonThreadYouhavejointhet1tomainYouhavetosuspendthemainwhenthethreadstartsandresumeitafterthevalueof'j'issetto100YouhavetointerruptthemainthreadAns:B7.Whatwill
7、happenifyoucompile/runthiscode?1:publicclassQ1implementsRunnable2:{3:publicvoidrun(Strings)4:{5:System.out.println("BeforestartThread:"+s);6:7:System.out.println("AfterstopofThread:"+s);8:}9:10:publicstaticvoidmain(String[]args)11:{12:Q1a=newQ1();13:Threa
8、dt=newThread(a);14:t.start();}15:}A)Compilationerroratline1B)Runtimeexceptionatline13.C)Compilationerroratline14D)Prints"BeforestartofThread"AfterStartofThreadAns:A8.classsimplementsRunnable{intx=0,y=0;intaddX(){x++
此文档下载收益归作者所有