SCJP模拟题

SCJP模拟题

ID:83420703

大小:6.28 MB

页数:97页

时间:2023-07-14

上传者:灯火阑珊2019
SCJP模拟题_第1页
SCJP模拟题_第2页
SCJP模拟题_第3页
SCJP模拟题_第4页
SCJP模拟题_第5页
SCJP模拟题_第6页
SCJP模拟题_第7页
SCJP模拟题_第8页
SCJP模拟题_第9页
SCJP模拟题_第10页
资源描述:

《SCJP模拟题》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

scjp⚪(■)QuestionNo:11.publicclasstest(2.publicstaticvoidmain(Stringargs[]){3.inti=OxFFFFFFFI;4.intj=~i;5.6.}7.)Whatisthedecimalvalueofjatline5?A.0B.1C.14D.-15EAnerroratline3causescompilationtofail.F.Anerroratline4causescompilationtofail.ᫀCQuestionNo:2Gven:Integeri=newInteger(42);Long1=newLong(42);Doubled=newDouble(42.0);WhichtwoexpressionsevaluatetoTrue?(ChooseTwo)A.(i==1)B.(i==d)C.(d==1)D.(i.equals(d))E.(d.equals(i))

1F.(i.equals(42))ᫀD,EQuestionNo:3Exhibit:1.publicclasstest(2.privatestaticintj=0;3.4.privatestaticbooleanmethodB(intk)(5.j+=k;6.returntrue;6.)7.8.publicstaticvoidmethodA(inti){9.booleanb:10.b=i<10|methodB(4);11.b=i<10||methodB(8);12.)13.14.publicstaticvoidmain(Stringargs[])(15.methodA(0);16.system.out.println(j);17.)18.)Whatistheresult?A.Theprogramprints“0”B.Theprogramprints“4”C.Theprogramprints“8”D.Theprogramprints“12”

2E.Thecodedoesnotcomplete.ᫀBQuestionNo:4Gven1.Publicclasstest(2.Publicstaticvoidmain(Stringargs[])(3.System.out.println(6A3);4.)5.)Whatistheoutput?ᫀ5QuestionNo:5Given:1.publicclassFoo{2.publicstaticvoidmain(String[]args){3.StringBuffera=newStringBuffer("A”)4.StringBufferb=newStringBuffer(uBn);5.operate(a,b);6.system.out.println{a++b};7.}8.staticvoidoperate(StringBufferx,StringBuffery){9.x.append{y};10.y=x;11)12.)Whatistheresult?A.Thecodecompilesandprints"A,B”.B.Thecodecompilesandprints"A,A”.

3C.ThecodecompilesandprintsD.Thecodecompilesandprints“AB,B”.E.Thecodecompilesandprints“AB,AB”.F.ThecodedoesnotcompilebecausecannotbeoverloadedforStringBuffer.ᫀDQuestionNo:6Exhibit:1.Publicclasstest(2.PublicstaticvoidstringReplace(Stringtext)(3.Text=text,replace('')4.)5.6.publicstaticvoidbufferReplace(StringBuffertext)(7.text=text.append("C')8.)9.10.publicstaticvoidmain(Stringargs[])(11.StringtextString=newString(“java”)12.StringBuffertextBufferstring=newStringBuffer(ujava");13.14.stringReplace(textstring);15.BufferReplace(textBuffer);16.17.System.out.printin(textstring+textBuffer);18.)19.)Whatistheoutput?ᫀJAVAJAVA

4QuestionNo:7Exhibit:1.publicclasstest{2.publicstaticvoidadd3(Integeri)}3.intval=i.intValue();4.val+=3;5.i=newInteger(val);6.)7.8.publicstaticvoidmain(Stringargs[]){9.Integeri=newInteger(0);10.add3(i);11.system.out.printin(i.intValue());12.)13.)Whatistheresult?A.Compilationwfail.B.Theprogramprints“0”.C.Theprogramprints“3”.D.Compilationwsucceedbutanexceptionwillbethrownatline3.ᫀBQuestionNo:8Gven:1.publicclassConstOver{2.publicConstCh/er(intx,inty,intz){3.)4.}WhichtwooverloadtheConstOverconstructor?(ChooseTwo)A.ConstOver(){}

5B.ProtectedintConstOver(){}C.PrivateConstOver(intz,inty,bytex){}D.PublicObjectConstOver(intx,inty,intz){}E.PublicvoidConstQ/er(bytex,bytey,bytez){}ᫀA,CQuestionNo:9Given:1.publicclassMethodOver{2.publicvoidsetVar(inta,intb,floatc){3.}4WhichtwooverloadthesetVarmethod?(ChooseTwo)A.PrivatevoidsetVar(inta,floatc,intb){}B.ProtectedvoidsetVar(inta,intb,floatc){}C.PublicintsetVar(inta,floatc,intb)(returna;)D.PublicintsetVar(inta,intb,floatc)(returna;)EProtectedfloatsetVar(inta,intb,floatc)(returnc;)ᫀA,CQuestionNo:10Gven:1.classBaseQass{2.Privatefloatx=1.0f;3.protectedfloatgetVar()(returnx;)4.}5.classSubclassextendsBaseQass(6.privatefloatx=2.0f;7.//insertcodehere8.)

6Whichtwoarevalidexamplesofmethodoverriding?(ChooseTwo)A.RoatgetVar(){returnx;}B.PublicfloatgetVar(){returnx;}C.FloatdoublegetVar(){returnx;}D.PublicfloatgetVar(){returnx;}EPublicfloatgetVar(floatf){returnf;}ᫀB,DQuestionNo:11Whichtwodemonstratean"isa"relationship?(ChooseTwo)A.publicinterfacePerson{}publicclassEmployeeextendsPerson{}B.publicinterfaceShape{}publicclassEmployeeextendsShape{}C.publicinterfaceColor{}publicclassEmployeeextendsColor{}D.publicclassSpecies{}publicclassAnimal(privateSpeciesspecies;)E.interfaceComponent{}0assContainerimplementsComponent(PrivateComponent[]children;)ᫀD,EQuestionNo:12Whichstatementistrue?A.Ananonymousinnerclassmaybedeclaredasfinal.B.Ananonymousinnerclasscanbedeclaredasprivate.C.Ananonymousinnerclasscanimplementmultipleinterfaces.D.Ananonymousinnerclasscanaccessfinalvariablesinanyenclosingscope.

7EConstructionofaninstanceofastaticinnerclassrequiresaninstanceoftheenclosingouterclass.ᫀDQuestionNo13Gven:1.packagetoo;2.3.publicclassOuter(4.publicstaticclassInner(5.)6.)Whichstatementistrue?A.AninstanceoftheInnerclasscanbeconstructedwith“newOuter.Inner()”B.Aninstanceoftheinnerclasscannotbeconstructedoutsideofpackagetoo.C.Aninstanceoftheinnerclasscanonlybeconstructedfromwithintheouterclass.D.Fromwithinthepackagebar,aninstanceoftheinnerclasscanbeconstructedwith“newinner஺"ᫀAQuestionNo14Exhibit:1.publicclassenclosingone(2.publicclassinsideone{}3.)4.publicclassinertest(5.publicstaticvoidmain(string[]args)(6.enclosingoneeo=newenclosingone();7.//insertcodehere8.)9.)Whichstatementatline7constructsaninstanceoftheinnerclass?

8A.InsideOnewei=eo.newlnsideOn();B.Eo.lnsideOneei=eo.newlnsideOne();C.InsideOneei=EnclosingOie.newlnsideOne();D.EnclosingOne.InsideOneei=eo.newlnsideOne();ᫀDQuestionNo15Exhibit:1.interfacetoo{2.intk=0;3.}4.5.publicclasstestimplementsFoo(6.publicstaticvoidmain(Stringargs[])(7.inti;8.Testtest=newtest();9.i=test.k;10.i=Test.k;11.i=Foo.k;12.)13.)14.Whatistheresult?A.Compilationsucceeds.B.Anerroratline2causescompilationtofail.C.Anerroratline9causescompilationtofail.D.Anerroratline10causescompilationtofail.E.Anerroratline11causescompilationtofail.ᫀA

9QuestionNo16Gven:1.//pointX2.publicclasstoo(3.publicstaticvoidmain(String஺args)throwsException{4.printwriterout=newPrintWriter(new5.java.io.outputStreamWriter(System.out),true;6.out.println("Hello");7.)8.}WhichstatementatPbintXonline1allowsthiscodetocompileandrun?A.Importjava.io.PrintWriter;B.Includejava.io.PrintWriter;C.Importjava.io.OutputStreamWriter;D.Includejava.io.outputStreamWriter;E.Nostatementisneeded.ᫀAQuestionNo17WhichtwostatementsarereservedwordsinJava?(ChooseTwo)A.RunB.ImportC.DefaultD.ImplementᫀB,CQuestionNo18Whichthreearevaliddeclarationsofafloat?(ChooseThree)A.Roattoo=-1;B.Aoattoo=1.0;

10C.Floattoo=42e1;D.Floattoo=2.02f;E.Floattoo=3.03d;F.Floattoo=0x0123;ᫀA,D,FQuestionNo19LeadingthewayinITtestingandcertificationtools,www.testkinq.comQuestionNo19Given:8.intindex=1;9.boolean[]test=newBoolean[3];10.booleanfoo=test[index];Whatistheresult?A.Foohasthevalueof0.B.Foohasthevalueofnull.C.Foohasthevalueoftrue.D.Foohasthevalueoffalse.E.Anexceptionisthrown.F.Thecodewillnotcompile.ᫀDQuestionNo20Gven:1.publicclasstest(2.publicstaticvoidmain(string[]args){3.stringtoo=args[1];4.stringtoo=args[2];5.stringtoo=args[3];6.}

117)Andcommandlineinvocation:JavaTestredgreenblueWhatistheresult?A.BazhasthevalueofB.BazhasthevalueofnullC.Bazhasthevalueof“red”D.Bazhasthevalueof“blue”E.Baxhasthevalueof“green”F.Thecodedoesnotcompile.G.Theprogramthrowsanexception.ᫀ:GQuestionNo21Given:8.intindex=1;9.int[]too=newint[3];1O.intbar=too[index];11.intbaz=bar+index;Whatistheresult?A.Bazhasthevalueof0B.Bazhasthevalueof1C.Bazhasthevalueof2D.Anexceptionisthrown.E.Thecodewillnotcompile.ᫀBQuestionNo22Given:1.publicclasstoo{

122.publicstaticvoidmain(String[]args){3.Strings;4.system.out.printin("s="+s);5}6.}Whatistheresult?A.Thecodecompilesand"s="isprinted.B.Thecodecompilesand“s=null"isprinted.C.Thecodedoesnotcompilebecausestringsisnotinitialized.D.Thecodedoesnotcompilebecausestringscannotbereferenced.E.Thecodecompiles,butaNullPointerExceptionisthrownwhentoStringiscalled.ᫀ:CQuestionNo23Whichwilldeclareamethodthatforcesasubclasstoimplementit?A.Publicdoublemethoda();B.Staticvoidmethods(doubled1){}C.Publicnativedoublemethoda();D.Abstractpublicvoidmethoda();E.Protectedvoidmethoda(doubled1){}ᫀDQuestionNo24Youwantsubclassesinanypackagetohaveaccesstomembersofasuperclass.Whichisthemostrestrictiveaccessmodifierthatwillaccomplishthisobjective?A.PublicB.PrivateC.ProtectedD.Transient

13ENoaccessmodifierisqualifiedᫀCQuestionNo25Gven:1.abstractclassabstrctlt{2.abstractfloatgetFloat();3.)4.publicclassAbstractTestextendsAbstractIt{5.privatefloatf1=1.0f;6.privatefloatgetRoat(){returnf1;}7Whatistheresult?A.Compilationissuccessful.B.Anerroronline6causesaruntimefailure.C.Anerroratline6causescompilationtofail.D.Anerroratline2causescompilationtofail.ᫀ:CQuestionNo26Exhibit:1.publicclasstest(2.publicintaMethod()[3.staticinti=0;4.i++;5.returnI;6.]7.publicstaticvoidmain(Stringargs[]){8.testtest=newtest();9.test.aMethod();

141O.intj=test.aMethod();11.System.out.println(j);12.)13.)Whatistheresult?A.Compilationwillfail.B.Compilationwillsucceedandtheprogramwillprint“0”C.CompilationwsucceedandtheprogramwillprintD.Compilationwillsucceedandtheprogramwillprint"2"ᫀDQuestionNo27Gven:1.classsuper{2.publicfloatgetNum(){return3.0f;}3.}4.5.publicclassSubextendsSuper{6.7.}Whichmethod,placedatline6,willcauseacompilererror?A.PublicfloatgetNum(){return4.0f;}B.PublicvoidgetNum(){}C.PublicvoidgetNum(doubled){}D.PublicdoublegetNum(floatd){retrun4.0f;}ᫀBQuestionNo28Whichdeclarationpreventscreatingasubclassofanouterclass?A.StaticclassFooBar{}

15B.PrivateclassFooBar{}C.AbstractpublicclassFooBar{}D.FinalpublicclassFooBar{}E.FnalabstractclassFooBar{}ᫀDQuestionNo29Given:1.byte[]arryl,array2[];2.bytearray3[][];3.byte[][]array4;Ifeacharrayhasbeeninitialized,whichstatementwillcauseacompilererror?A.Array2=array1;B.Array2=array3;C.Array2=array4;D.BothAandBE.BothAandCF.BothBandCᫀFQuestionNo30Exhibit:1.classsuper(2.publicintI=0;3.4.publicsuper(stringtext)(5.I=16.)7.)8.

169.publicclasssubextendssuper(10.publicsub(stringtext)(11.i=212.)13.14.publicstaticvoidmain(straingargs[])(15.subsub=newsub("Hello")16.system.out.Println(sub.i);17.)18.)Whatistheresult?A.Compilationwillfail.B.Compilationwillsucceedandtheprogramwillprint“0”C.Compilationwillsucceedandtheprogramwillprintu1>,D.Compilationwillsucceedandtheprogramwillprint“2”ᫀAQuestionNo31Given:1.publicclassreturnlt(2.returnTypemethodA(bytex,doubley)(3.return(short)x/y*2;4.)5.)WhatisthevalidreturnTypeformethodAinline2?A.IntB.ByteC.LongD.ShortE.Float

17F.DoubleᫀFQuestionNo32GventheActionEvent,whichmethodallowsyoutoidentifytheaffectedcomponent?A.GetClass.B.GetTarget.C.GetSource.D.GetComponent.E.GetTargetComponent.ᫀCQuestionNo33WhichisamethodoftheMouseMotionListenerinterface?A.PublicvoidmouseMoved(MouseEvent)B.PublicbooleanmouseMoved(MouseEvent)C.PublicvoidmouseMoved(MouseMotionEvent)D.PublicbooleanMouseMoved(MouseMotionEvent)E.PublicbooleanmouseMoved(MouseMotionEvent)ᫀAQuestionNo34Exhibit:1.importjava.awt*;2.3.publicclassXextendsFrame(4.publicstaticvoidmain(string[]args)(5.Xx=newX();6.X.pack();7.x.setVisible(true);8.)

189.10.publicX()(11.setlayout(newGridLayout(2,2));12.13.Panelp1=newpanel();14.Add(p1);15.Buttonb1=newButton(“One”);16.P1.add(b1);17.18.Panelp2=newpanel();19.Add(p2);20.Buttonb2=newButton(“Two”)21.P2.add(b2);22.23.Buttonb3=newButton("Three")24.add(b3);25.26.Buttonb4=newButton(“Four”)27.add(b4);28.)29.)Whichtwostatementsaretrue?(ChooseTwo)A.Allthebuttonschangeheightiftheframeheightisresized.B.AllthebuttonschangewidthiftheFramewidthisresized.C.Thesizeofthebuttonlabeled“One”isconstanteveniftheFrameisresized.D.Bothwidthandheightofthebuttonlabeled“Three”mightchangeiftheFrameisresized.ᫀC,DQuestionNo35YouareassignedthetaskofbuildingapanelcontainingaTextAreaatthetop,alabeldirectlybelow

19it,andabuttondirectlybelowthelabel.Ifthethreecomponentsareaddeddirectlytothepanel.WhichlayoutmanagercanthepanelusetoensurethattheTextAreaabsorbsallofthefreeverticalspacewhenthepanelisresized?A.GridLayout.B.CardLayout.C.FowLayout.D.BorderLayout.EGridBagLayout.ᫀEQuestionNo36Whichgetsthenameoftheparentdirectoryfile"file.txt"?A.Stringname=File.getParentName(afile.txtM);B.Stringname=(newFile(Hfile.txtM)).getRarent();C.Stringname=(newFle(Mfile.txtn)).getParentName();D.Stringname=(newFile(ufile.txtH)).getParentHle();E.Directorydir=(newFile(ile.txtM)).getParentDir();Stringname=dir.getName();ᫀBQuestionNo37WhichcanbeusedtoencodecharSforoutput?A.Java.io.OutputStream.B.Java.io.OutputstreamWriter.C.Java.io.EncodeOutputStream.D.Java.io.EncodeWriter.EJava.io.BufferedOutputStream.ᫀB

20QuestionNo38ThefileexistsonthefilesystemandcontsinsASCIItext.Given:38.try{39.Hlef=newHle(Hfile.txtn);40.Outputstreamout=newFleOutputStream(f,true);41.)42.catch(lOException){}Whatistheresult?A.Thecodedoesnotcompile.B.Thecoderunsandnochangeismadetothefile.C.Thecoderunsandsetsthelengthofthefileto0.D.Anexceptionisthrownbecausethefileisnotclosed.E.Thecoderunsanddeletesthefilefromthefilesystem.ᫀAQuestionNo39WhichconstructsaDataOutputStream?A.NewdataOutputStrearn(uout.txtM);B.NewdataOutputStream(newfile(Hout.txf,));C.NewdataOutputStream(newwriter(Mout.txt"));D.NewdataOutputStream(newFileWriter(uout.txtn));ENewdataOutputStream(newCXitputStream(uout.txtn))F.NewdataOutputStream(newFileOutputStream(uout.txf,))ᫀFQuestionNo40Whatwritesthetextuntotheendofthefile“file.txt”A.CXitputStreamout=newFileOutputStream("file.txt”)Out.writeBytes(7nn);

21B.Outputstreamos=newFileOutputStream(ufile.txtH,true);DataOutputStreamout=newDataOutputStream(os);out.writeBytes(7nn)C.Outputstreamos=newFileOutputStream("file.txt");DataOutputStreamout=newDataOutputStream(os);out.writeBytes(7nn);D.Outputstreamos=newOutputStream("file.txt"true);DataOutputStreamout=newDataOutputStream(os);out.writeBytes(H/nn);ᫀBQuestionNo41Gven:1.publicclassX(2.publicobjectm(){3.objecto=newfloat(3.14F);4.object[]oa=newobject[1];5.oa[0]=o;6.o=null;7.returnoa[0];89.)Whenisthefloatobjectcreatedinline3,eligibleforgarbagecollection?A.Justafterline5B.Justafterline6C.Justafterline7(thatis,asthemethodreturns)D.Neverinthismethod.ᫀD

22QuestionNo42Gven:3.stringtoo="ABODE”4.foo.substring(3);5.foo.concat(MXYZn);6.Typethevalueoffooatline6.ᫀABCDEQuestionNo43Whichmethodisanappropriatewaytodeterminethecosineof42degrees?A.Doubled=Math.cos(42);B.Doubled=Math.cosine(42);C.Doubled=Math.cos(Math.toRadians(42));D.Doubled=Math.cos(Math.toDegrees(42));E.Doubled=Math.cosine(Math.toRadians(42));ᫀCQuestionNo44Youneedtostoreelementsinacollectionthatguaranteesthatnoduplicatesarestoredandallelementscanbeaccessedinnaturalorder.Whichinterfaceprovidesthatcapability?A.Java.util.Map.B.Java.util.Set.C.Java.util.List.D.Java.util.StoredSet.E.Java.util.StoredMap.F.Java.util.Collection.ᫀD

23QuestionNo45Whichstatementistruefortheclassjava.util.HashSet?A.Theelementsinthecollectionareordered.B.Thecollectionisguaranteedtobeimmutable.C.Theelementsinthecollectionareguaranteedtobeunique.D.Theelementsinthecollectionareaccessedusingauniquekey.E.Theelementsinthecollectionsareguaranteedtobesynchronized.ᫀCQuestionNo46Gven:1.publicclassIfTest(2.publicstaticvoidmain(string[]args){3.intx=3;4.inty=1;5.if(x=y)6.system.out.printIn(uNotequal");7.else8.system.out.println(uEquar,);9.}10.)Whatistheresult?A.Theoutputis“Equal”B.Theoutputin“NotEqual"C.Anerroratline5causescompilationtofall.D.Theprogramexecutesbutdoesnotprintamessage.ᫀCQuestionNo47Exhibit:

241.publicclasstest(2.publicstaticvoidmain(stringargs[]){3.int1=0;4.while(i){5.if(i==4){6.break;7}8.++i9}10.11)12.)Whatisthevalueofiatline10?A.0B.3C.4D.5E.Thecodewillnotcompile.ᫀEQuestionNo48Gven:3.inti=1,j=10;4.do(5.if(i++>-j)continue;6.)while(i<5);Afterexecution,whatarethevaluesforIandj?A.i=6andj=5B.i=5andj=5C.i=6andj=4

25D.i=5andj=6E.i=6andj=6ᫀDQuestionNo49Gven:1.switch(i){2.default:310-025LeadingthewayinITtestingandcertificationtools,www.testkinq.com-27-3.System.out.println("Hello")4.}Whatarethetwoacceptabletypesforthevariablei?(ChooseTwo)A.CharB.ByteC.FloatD.DoubleE.ObjectᫀA,BQuestionNo50Gven:1.publicclasstoo{2.publicstaticvoidmain(string[]args)3.try{return;}4.finally{system.out.println(MFinallyM)}5}6.}Whatistheresult?

26A.Theprogramrunsandprintsnothing.B.Theprogramrunsandprints“Finally”C.Thecodecompiles,butanexceptionisthrownatruntime.D.Thecodewillnotcompilebecausethecatchblockismissing.ᫀBQuestionNo5151.WhichcorrectlycreateanarrayoffiveemptyStrings?A.Stringa[]=newString[5];for(inti=0;i<5;a[i++]=,,n);B.Bringa□=C.Stringa[5];D.String[5]a;EString[]a=newString[5];for(inti=0;i<5;a[i++]=null);ᫀ:AஹBQuestionNo5252.WhichcannotbeaddedtoaContainer?A.anAppletB.aComponentC.aContainerD.aMenuComponentE.apanelᫀ:DQuestionNo5353.WhichisthereturnvalueofEventlistener?smethod?A.StringB.AWTEventC.voidD.intᫀ:C

27QuestionNo5454.IfweimplementsMouseListener,whichiscorrectedargumentofitsmethod?(shortanswer)ᫀMouseEventQuestionNo5555.Usetheoperator">>"andH>>>M.Whichstatementistrue?A.10100000000000000000000000000000>>4give00001010000000000000000000000000B.10100000000000000000000000000000>>4give11111010000000000000000000000000C.10100000000000000000000000000000>>>4give00001010000000000000000000000000D.10100000000000000000000000000000>>>4give11111010000000000000000000000000ᫀBஹCQuestionNo5656.Gvefollowingfragment.Outer:for(inti=0;i<3;i++)inner:for(intj=0;j<3;j++){lf(j>1)breakouter;System.out.println(j+”and"+i);)Whichwillbeoutput?A.0and0B.0and1C.0and2D.0and3E.1and0F.1and1G.1and2H.1and3I.2and0J.2and1K.2and2L2and3ᫀAஹEQuestionNo5757.Examinethefollowingcodewhichincludesaninnerclass:

28publicfinalclassTest4implementsA{classlnner{voidtest(){if(Test4.this.flag);{sample();))privatebooleanflag=false;)publicvoidsample(){System.out.prin11n(HSampleH);)publicTest4(){(newlnner()).test();)publicstaticvoidmain(Stringargs[]){newTest4();))Whatistheresult:A.Printout“Sample”B.Programproducesnooutputbuttermiantescorrectly.C.Programdoesnotterminate.D.Theprogramwillnotcompileᫀ:AQuestionNo5858.Whatiswrittentothestandardoutputgiventhefollowingstatement:System.out.println(4|7);Selecttherightanswer:

29A.4B.5C.6D.7E.0ᫀ:DQuestionNo5959.Looktheinheritancerelation:personIImanwomanInasourceofjavahavethefollowingline:personp=newman();Whatstatementarecorrected?A.Theexpressionisillegal.B.Compilecorrectedbutrunningwrong.C.Theexpressionislegal.D.Willconstructaperson?sobject.ᫀ:CQuestionNo6060.Looktheinheritancerelation:personIImanwoman

30Inasourceofjavahavethefollowingline:womanw=newman():Whatstatementarecorrected?A.Theexpressionisillegal.B.Compilecorrectedbutrunningwrong.C.Theexpressionislegal.D.Willconstructawomanobject.ᫀ:AQuestionNo6161.WhichcanNOTbeusedindeclaringordeclaringandinitializinganautomatic(methodlocal)variable?A.finalB.staticC.expressionsD.Constantsofnon-primitivetypeE.initializedarrays(suchas”{"Hello","Goodbye"}").ᫀ:Bscjp⚪()QuestionNo:1publicclasstest(2.publicstaticvoidmain(Stringargs[]){3.inti=OxFFFFFFFI;4.intj=~i

315.6.}7.)Whatisthedecimalvalueofjatline5?A.0B.1C.14D.-15E.Anerroratline3causescompilationtofail.F.Anerroratline4causescompilationtofail.ᫀCQuestionNo:2Gven:Integeri=newInteger(42);Long1=newLong(42);Doubled=newDouble(42.0);WhichtwoexpressionsevaluatetoTrue?(ChooseTwo)A.(i==1)B.(i==d)C.(d==1)D.(i.equals(d))E(d.equals(i))F.(i.equals(42))ᫀD,EQuestionNo:3Exhibit:1.publicclasstest(2.privatestaticintj=0;

323.4.privatestaticbooleanmethodB(intk)(5.j+=k;6.returntrue;6.)7.8.publicstaticvoidmethodA(inti){9.booleanb:10.b=i<10|methodB(4);11.b=i<10||methodB(8);12.}13.14.publicstaticvoidmain(Stringargs[])(15.methodA(0);16.system.out.println(j);17.)18.)Whatistheresult?A.Theprogramprints“0”B.Theprogramprints“4”C.Theprogramprints“8”D.Theprogramprints“12”E.Thecodedoesnotcomplete.ᫀ:BQuestionNo:4Given1.Publicclasstest(2.Publicstaticvoidmain(Stringargs[])(3.System.out.println(6A3);

334.)5.)Whatistheoutput?ᫀ5QuestionNo:5Gven:1.publicclassFoo{2.publicstaticvoidmain(String[]args){3.StringBuffera=newStringBuffer(uAn);4.StringBufferb=newStringBuffer(“B”)5.operate(a,b);6.system.out.println{a+“J+b);7.}8.staticvoidoperate(StringBufferx,StringBuffery){9.x.append{y};10.y=x;11.)12.)Whatistheresult?A.ThecodecompilesandprintsB.Thecodecompilesandprints"A,A”.C.ThecodecompilesandprintsD.ThecodecompilesandprintsE.Thecodecompilesandprints“AB,AB”.F.ThecodedoesnotcompilebecausecannotbeoverloadedforStringBuffer.ᫀDQuestionNo:6Exhibit:

341.Publicclasstest(2.PublicstaticvoidstringReplace(Stringtext)(3.Text=text.replace(1'')4.)5.6.publicstaticvoidbufferReplace(StringBuffertext)(7.text=text.append("C')8.)9.10.publicstaticvoidmain(Stringargs[])(11.StringtextString=newString(“java”)12.StringBuffertextBufferstring=newStringBuffer(“java");13.14.stringReplace(textString);15.BufferReplace(textBuffer);16.17.System.out.printin(textString+textBuffer);18.)19.)Whatistheoutput?ᫀJAVAJAVAQuestionNo:7Exhibit:1.publicclasstest{2.publicstaticvoidadd3(Integeri)}3.intval=i.intValue();4.val+=3;5.i=newInteger(val);6.)

357.8.publicstaticvoidmain(Stringargs[]){9.Integeri=newInteger(0);10.add3(i);11.system.out.printin(i.intValue());12.}13.)Whatistheresult?A.Compilationwillfail.B.Theprogramprints“0”.C.Theprogramprints“3”.D.Compilationwillsucceedbutanexceptionwillbethrownatline3.ᫀBQuestionNo:8Gven:1.publicclassConstCX/er{2.publicConstO/er(intx,inty,intz){3.}4.}WhichtwooverloadtheConstOverconstructor?(ChooseTwo)A.ConstOver(){}B.ProtectedintConstOver(){}C.PrivateConstOver(intz,inty,bytex){}D.PublicObjectConstOver(intx,inty,intz){}EPublicvoidConstOver(bytex,bytey,bytez){}ᫀA,CQuestionNo:9Gven:

361.publicclassMethodQ/er{2.publicvoidsetVar(inta,intb,floatc){3.}4.}WhichtwooverloadthesetVarmethod?(ChooseTwo)A.PrivatevoidsetVar(inta,floatc,intb){}B.ProtectedvoidsetVar(inta,intb,floatc){}C.PublicintsetVar(inta,floatc,intb)(returna;)D.PublicintsetVar(inta,intb,floatc)(returna;)EProtectedfloatsetVar(inta,intb,floatc)(returnc;)ᫀA,CQuestionNo:10Gven:1.classBaseQass{2.Privatefloatx=1.0f;3.protectedfloatgetVar()(returnx;)4.}5.classSubclassextendsBaseQass(6.privatefloatx=2.0f;7.//insertcodehere8.)Whichtwoarevalidexamplesofmethodoverriding?(ChooseTwo)A.FloatgetVar(){returnx;}B.PublicfloatgetVar(){returnx;}C.FloatdoublegetVar(){returnx;}D.PublicfloatgetVar(){returnx;}E.PublicfloatgetVar(floatf){returnf;}ᫀB,D

37QuestionNo:11Whichtwodemonstratean“isaMrelationship?(ChooseTwo)A.publicinterfacePerson{}publicclassEmployeeextendsPerson{}B.publicinterfaceShape{}publicclassEmployeeextendsShape{}C.publicinterfaceColor{}publicclassEmployeeextendsColor{}D.publicclassSpecies{}publicclassAnimal(privateSpeciesspecies;)E.interfaceComponent{}ClassContainerimplementsComponent(PrivateComponent!]children;)ᫀD,EQuestionNo:12Whichstatementistrue?A.Ananonymousinnerclassmaybedeclaredasfinal.B.Ananonymousinnerclasscanbedeclaredasprivate.C.Ananonymousinnerclasscanimplementmultipleinterfaces.D.Ananonymousinnerclasscanaccessfinalvariablesinanyenclosingscope.EConstructionofaninstanceofastaticinnerclassrequiresaninstanceoftheenclosingouterclass.ᫀDQuestionNo13Gven:1.packagefoo;2.3.publicclassOuter(

384.publicstaticclassInner(5.)6.)Whichstatementistrue?A.AninstanceoftheInnerclasscanbeconstructedwith“newOuter.lnner()”B.Aninstanceoftheinnerclasscannotbeconstructedoutsideofpackagetoo.C.Aninstanceoftheinnerclasscanonlybeconstructedfromwithintheouterclass.D.Fromwithinthepackagebar,aninstanceoftheinnerclasscanbeconstructedwith“newinner஺"ᫀAQuestionNo14Exhibit:1.publicclassenclosingone(2.publicclassinsideone{}3.)4.publicclassinertest(5.publicstaticvoidmain(string[]args)(6.enclosingoneeo=newenclosingone();7.//insertcodehere8.)9.)Whichstatementatline7constructsaninstanceoftheinnerclass?A.InsideOnewei=eo.newlnsideOn();B.Eo.lnsideOneei=eo.newlnsideOne();C.InsideOneei=EnclosingOne.newlnsideOne();D.EnclosingOne.InsideOneei=eo.newlnsideOne();ᫀDQuestionNo15Exhibit:

391.interfacetoo{2.intk=0;3.}4.5.publicclasstestimplementsFoo(6.publicstaticvoidmain(Stringargs[])(7.inti;8.Testtest=newtest();9.i=test.k;1O.i=Test.k;11.i=Foo.k;12.)13.)14.Whatistheresult?A.Compilationsucceeds.B.Anerroratline2causescompilationtofail.C.Anerroratline9causescompilationtofail.D.Anerroratline10causescompilationtofail.E.Anerroratline11causescompilationtofail.ᫀAQuestionNo16Gven:1.//pointX2.publicclasstoo(3.publicstaticvoidmain(String[]args)throwsException{4.printwriterout=newPrintwriter(new5.java.io.outputStreamWriter(^stem.out),true;6.out.println(,,Hellon);

407)8.}WhichstatementatPointXonline1allowsthiscodetocompileandrun?A.Importjava.io.PrintWriter;B.Includejava.io.PrintWriter;C.Importjava.io.OutputStreamWriter;D.Includejava.io.OutputstreamWriter;E.Nostatementisneeded.ᫀAQuestionNo17WhichtwostatementsarereservedwordsinJava?(ChooseTwo)A.RunB.ImportC.DefaultD.ImplementᫀB,CQuestionNo18Whichthreearevaliddeclarationsofafloat?(ChooseThree)A.Floattoo=-1;B.Floattoo=1.0;C.Roattoo=42e1;D.Floatfoo=2.02f;EFloatfoo=3.03d;F.Floatfoo=0x0123;ᫀA,D,FQuestionNo19LeadingthewayinITtestingandcertificationtools,www.testking.comQuestionNo19

41Gven:8.intindex=1;9.boolean[]test=newBoolean[3];10.booleanfoo=test[index];Whatistheresult?A.Foohasthevalueof0.B.Foohasthevalueofnull.C.Foohasthevalueoftrue.D.Foohasthevalueoffalse.EAnexceptionisthrown.F.Thecodewillnotcompile.ᫀDQuestionNo20Given:1.publicclasstest(2.publicstaticvoidmain(string[]args){3.stringtoo=args[1];4.stringtoo=args[2];5.stringtoo=args[3];6.}7.)Andcommandlineinvocation:JavaTestredgreenblueWhatistheresult?A.BazhasthevalueofttMB.BazhasthevalueofnullC.Bazhasthevalueof“red”D.Bazhasthevalueof“blue”E.Baxhasthevalueof“green”

42F.Thecodedoesnotcompile.GTheprogramthrowsanexception.ᫀGQuestionNo21Gven:8.intindex=1;9.int[]too=newint[3];1O.intbar=foo[index];11.intbaz=bar+index;Whatistheresult?A.Bazhasthevalueof0B.Bazhasthevalueof1C.Bazhasthevalueof2D.Anexceptionisthrown.EThecodewillnotcompile.ᫀBCXjestionNo22Gven:1.publicclassfoo{2.publicstaticvoidmain(String[]args){3.Strings;4.system.out.printin("s="+s);5.}6.}Whatistheresult?A.Thecodecompilesand"s="isprinted.B.Thecodecompilesand“s=null"isprinted.C.Thecodedoesnotcompilebecausestringsisnotinitialized.

43D.Thecodedoesnotcompilebecausestringscannotbereferenced.EThecodecompiles,butaNullPointerExceptionisthrownwhentoStringiscalled.ᫀCQuestionNo23Whichwilldeclareamethodthatforcesasubclasstoimplementit?A.Publicdoublemethoda();B.Staticvoidmethoda(doubled1){}C.Publicnativedoublemethoda();D.Abstractpublicvoidmethoda();EProtectedvoidmethoda(doubled1){}ᫀDQuestionNo24Youwantsubclassesinanypackagetohaveaccesstomembersofasuperclass.Whichisthemostrestrictiveaccessmodifierthatwillaccomplishthisobjective?A.PublicB.PrivateC.ProtectedD.TransientENoaccessmodifierisqualifiedᫀCQuestionNo25Gven:1.abstractclassabstrctlt{2.abstractfloatgetFloat();3.)4.publicclassAbstractTestextendsAbstracts{5.privatefloatf1=1.0f;6.privatefloatgetFloat(){returnf1;}

447}Whatistheresult?A.Compilationissuccessful.B.Anerroronline6causesaruntimefailure.C.Anerroratline6causescompilationtofail.D.Anerroratline2causescompilationtofail.ᫀCQuestionNo26Exhibit:1.publicclasstest(2.publicintaMethod()[3.staticinti=0;4.i++;5.returnI;6.]7.publicstaticvoidmain(Stringargs[]){8.testtest=newtest();9.test.aMethod();1O.intj=test.aMethod();11.System.out.println(j);12.)13.)Whatistheresult?A.Compilationwillfail.B.Compilationwillsucceedandtheprogramwillprint“0”C.CompilationwillsucceedandtheprogramwillprintTD.Compilationwillsucceedandtheprogramwillprint“2”ᫀD

45QuestionNo27Gven:1.classsuper{2.publicfloatgetNum(){return3.0f;}3.}4.5.publicclassSubextendsSuper{6.7Whichmethod,placedatline6,willcauseacompilererror?A.PublicfloatgetNum(){return4.0f;}B.PublicvoidgetNum(){}C.PublicvoidgetNum(doubled){}D.PublicdoublegetNum(floatd){retrun4.0f;}ᫀBQuestionNo28Whichdeclarationpreventscreatingasubclassofanouterclass?A.StaticclassFooBar{}B.PrivateclassFooBar{}C.AbstractpublicclassFooBar{}D.FnalpublicclassFooBar{}E.FinalabstractclassFooBar{}ᫀDQuestionNo29Gven:1.byte[]arryl,array2[];2.bytearray3[][];3.byte[][]array4;

46Ifeacharrayhasbeeninitialized,whichstatementwillcauseacompilererror?A.Array2=array1;B.Array2=array3;C.Array2=array4;D.BothAandBEBothAandCF.BothBandCᫀFQuestionNo30Exhibit:1.classsuper(2.publicintI=0;3.4.publicsuper(stringtext)(5.I=16.)7.)8.9.publicclasssubextendssuper(10.publicsub(stringtext)(11.i=212.)13.14.publicstaticvoidmain(straingargs[])(15.subsub=newsub("Hello")16.system.out.Println(sub.i);17.)18.)Whatistheresult?

47A.Compilationwillfail.B.Compilationwillsucceedandtheprogramwillprint“0”C.CompilationwillsucceedandtheprogramwillprintH1MD.Compilationwillsucceedandtheprogramwillprint“2”ᫀAQuestionNo31Given:1.publicclassreturnlt(2.returnTypemethodA(bytex,doubley)(3.return(short)x/y*2;4.)5.)WhatisthevalidreturnTypeformethodAinline2?A.IntB.ByteC.LongD.ShortE.RoatF.DoubleᫀFQuestionNo32GventheActionEvent,whichmethodallowsyoutoidentifytheaffectedcomponent?A.GetQass.B.GetTarget.C.GetSource.D.GetComponent.EGetTargetComponent.ᫀC

48QuestionNo33WhichisamethodoftheMouseMotionListenerinterface?A.FliblicvoidmouseMoved(MouseEvent)B.PublicbooleanmouseMoved(MouseEvent)C.PublicvoidmouseMoved(MouseMotionEvent)D.PublicbooleanMouseMoved(MouseMotionEvent)E.PublicbooleanmouseMoved(MouseMotionEvent)ᫀAQuestionNo34Exhibit:1.importjava.awt*;2.3.publicclassXextendsFrame(4.publicstaticvoidmain(string[]args)(5.Xx=newX();6.X.pack();7.x.setVisible(true);8.)9.10.publicX()(11.setlayout(newGridLayout(2,2));12.13.Panelp1=newpanel();14.Add(p1);15.Buttonb1=newButton(“One”)16.P1.add(b1);17.18.Panelp2=newpanel();19.Add(p2);

4920.Buttonb2=newButton(“Two”);21.P2.add(b2);22.23.Buttonb3=newButton("Three")24.add(b3);25.26.Buttonb4=newButton(“Four”)27.add(b4);28.)29.)Whichtwostatementsaretrue?(ChooseTwo)A.Allthebuttonschangeheightiftheframeheightisresized.B.AllthebuttonschangewidthiftheFramewidthisresized.C.Thesizeofthebuttonlabeled“One”isconstanteveniftheFrameisresized.D.Bothwidthandheightofthebuttonlabeled“Three”mightchangeiftheFrameisresized.ᫀC,DQuestionNo35YouareassignedthetaskofbuildingapanelcontainingaTextAreaatthetop,alabeldirectlybelowit,andabuttondirectlybelowthelabel.Ifthethreecomponentsareaddeddirectlytothepanel.WhichlayoutmanagercanthepanelusetoensurethattheTextAreaabsorbsallofthefreeverticalspacewhenthepanelisresized?A.GridLayout.B.CardLayout.C.RowLayout.D.BorderLayout.EGridBagLayout.ᫀE

50QuestionNo36Whichgetsthenameoftheparentdirectoryfile“file.txt"?A.Stringname=File.getRarentName(Hfile.txtM);B.Stringname=(newFile(Mfile.txtn)).getRarent();C.Stringname=(newFile(Mfile.txtn)).getParentName();D.Stringname=(newFile(wfile.txtH)).getParentFle();E.Directorydir=(newFile(HfiIe.txtM)).getParentDir();Stringname=dir.getName();ᫀBQuestionNo37WhichcanbeusedtoencodecharSforoutput?A.Java.io.OutputStream.B.Java.io.OutputStreamWriter.C.Java.io.EncodeOutputStream.D.Java.io.EncodeWriter.E.Java.io.BufferedOutputStream.ᫀBQuestionNo38Thefile“file.txt"existsonthefilesystemandcontsinsASCIItext.Gven:38.try{39.Filef=newFile(ufile.txtH);40.Outputstreamout=newFileOutputStream(f,true);41.)42.catch(lOException){}Whatistheresult?A.Thecodedoesnotcompile.B.Thecoderunsandnochangeismadetothefile.

51C.Thecoderunsandsetsthelengthofthefileto0.D.Anexceptionisthrownbecausethefileisnotclosed.E.Thecoderunsanddeletesthefilefromthefilesystem.ᫀAQuestionNo39WhichconstructsaDataOutputStream?A.NewdataOutputStrearn(uout.txtM);B.NewdataOutputStream(newfile(Hout.txf,));C.NewdataOutputStream(newwriter(Mout.txt"));D.NewdataOutputStream(newFileWriter(uout.txtn));ENewdataOutputStream(newCXitputStream(uout.txtn))F.NewdataOutputStream(newFileOutputStream(uout.txf,))ᫀFQuestionNo40Whatwritesthetextuntotheendofthefile“file.txt”A.CXitputStreamout=newFileOutputStream("file.txt”)Out.writeBytes(7nn);B.Outputstreamos=newFileOutputStream("file.txt"true);DataOutputStreamout=newDataOutputStream(os);Out.writeBytes(Vn*1);C.Outputstreamos=newFileOutputStream("file.txt”)DataOutputStreamout=newDataOutputStream(os);Out.writeBytes(7nn);D.Outputstreamos=newOutputstream("file.txt"true);DataOutputStreamout=newDataOutputStream(os);Out.writeBytes(c7nn);ᫀB

52QuestionNo41Gven:1.publicclassX(2.publicobjectm(){3.objecto=newfloat(3.14F);4.object[]oa=newobject[1];5.oa[0]=o;6.o=null;7.returnoa[0];8.}9.)Whenisthefloatobjectcreatedinline3,eligibleforgarbagecollection?A.Justafterline5B.Justafterline6C.Justafterline7(thatis,asthemethodreturns)D.Neverinthismethod.ᫀDQuestionNo42Gven:3.stringtoo="ABODE”4.foo.substring(3);5.foo.concat(4,XYZn);6.Typethevalueoftooatline6.ᫀABCDEQuestionNo43Whichmethodisanappropriatewaytodeterminethecosineof42degrees?A.Doubled=Math.cos(42);

53B.Doubled=Math.cosine(42);C.Doubled=Math.cos(Math.toRadians(42));D.Doubled=Math.cos(Math.toDegrees(42));E.Doubled=Math.cosine(Math.toRadians(42));ᫀCQuestionNo44Youneedtostoreelementsinacollectionthatguaranteesthatnoduplicatesarestoredandallelementscanbeaccessedinnaturalorder.Whichinterfaceprovidesthatcapability?A.Java.util.Map.B.Java.util.Set.C.Java.util.List.D.Java.util.StoredSet.E.Java.util.StoredMap.F.Java.util.Collection.ᫀDCXjestionNo45Whichstatementistruefortheclassjava.util.HashSet?A.Theelementsinthecollectionareordered.B.Thecollectionisguaranteedtobeimmutable.C.Theelementsinthecollectionareguaranteedtobeunique.D.Theelementsinthecollectionareaccessedusingauniquekey.E.Theelementsinthecollectionsareguaranteedtobesynchronized.ᫀCQuestionNo46Gven:1.publicclassIfTest(2.publicstaticvoidmain(string[]args){

543.intx=3;4.inty=1;5.if(x=y)6.system.out.printIn(uNotequal")7.else8.system.out.println(uEquar,);9.}10.)Whatistheresult?A.Theoutputis“Equal”B.Theoutputin"NotBjual"C.Anerroratline5causescompilationtofall.D.Theprogramexecutesbutdoesnotprintamessage.ᫀCQuestionNo47Exhibit:1.publicclasstest(2.publicstaticvoidmain(stringargs[]){3.int1=0;4.while(i){5.if(i==4){6.break;78.++i9}10.11)12.)Whatisthevalueofiatline10?

55A.0B.3C.4D.5E.Thecodewillnotcompile.ᫀEQuestionNo48Given:3.inti=1,j=10;4.do(5.if(i++>-j)continue;6.)while(i<5);Afterexecution,whatarethevaluesforIandj?A.i=6andj=5B.i=5andj=5C.i=6andj=4D.i=5andj=6E.i=6andj=6ᫀ:DQuestionNo49Given:1.switch(i){2.default:310-025LeadingthewayinITtestingandcertificationtools,www.testkinq.com-27-3.System.out.printIn(uHelloM);4}

56Whatarethetwoacceptabletypesforthevariablei?(ChooseTwo)A.CharB.ByteC.FloatD.DoubleEObjectᫀA,BQuestionNo50Given:1.publicclasstoo{2.publicstaticvoidmain(string[]args)3.try{return;}4.finally{system.out.println(uFinallyn);}5.}6.}Whatistheresult?A.Theprogramrunsandprintsnothing.B.Theprogramrunsandprints“Finally”C.Thecodecompiles,butanexceptionisthrownatruntime.D.Thecodewillnotcompilebecausethecatchblockismissing.ᫀBQuestionNo5151.Giventhefollowingincompletemethod:1)publicvoidmethod(){2)3}if(someTestFails()){4)5)}

576}7}}YouwanttomakethismethodthrowanlOExceptionif,andonlyif,themethodsomeTestFails()returnsavalueoftrue.Whichchangesachievethis?A.Addatline2:lOExceptione;B.Addatline4:throwe;C.Addatline4:thrownewIOException();D.Addatline6:thrownewIOException();EModifythemethoddeclarationtoindicatethatanobjectoftypeExceptionmightbethrown.ᫀCஹEQuestionNo5252.Giventhefollowingdefinition:Strings=null;WhichcodefragmentscauseanobjectoftypeNullPointerExceptiontobethrown?A.if((s!=null)&(s.length()>0))B.if((s!=null)&&(s.length()>0))C.if((s==null)|(s.length()==O))D.if((s==null)||(s.length()==0))ᫀAஹCQuestionNo5353.Thefollowingisaprogram1)classExsuper{2}Stringname;3}Stringnick_name;4)5}publicExSuper(Strings,Stringt){6}name=s;

587}nick_name=t;8))9)10}publicstringtoString(){11}returnname;12}}13))14)15)publicclassExampleextendsExSuper{16)17}publicExample(Strings,Stringt){18}super(s,t);19))20)21}publicStringtoString(){22}returnname+na.k.an+nick_name;23))24)25}publicstaticvoidmain(Stringargs[]){26}ExSupera=newExSuper(MFrstH,M1stH);27}ExSuperb=newExample(uSecond7,2ndn);28)29}System.out.println(uaisH+a.toString());30}System.out.println(ubisH+b.toString());31))32))Whathappenswhentheuserattemptstocompileandrunthisprogram?'A.ACompilererroroccursatline21B.AnobjectoftypeQassCastExceptionisthrownatline27C.Thefollowingoutput:

59aisFirstbissecondD.Thefollowingoutput:aisFirstbisSeconga.k.a2ndF.Thefollowingoutput:aisFrsta.k.a1stbisSeconda.k.a2ndᫀ:DQuestionNo5454.WhichstatementsaretrueaboutListeners?A.AtmostonelistenercanbeaddedtoanysimpleComponent.B.ThereturnvaluefromalistenerisusedtocontroltheinvocationofotherlistenerC.Ifmultiplelistenersareaddedtoasinglecomponent,theymustallbemadefriendstoeachotherD.Ifmultiplelistenersareaddedtosinglecomponent,theorderofinvocationofthelistenerisnotspecified.EIntheAWT,listenermethodsgenerallytakeanargument,whichisaninstanceofsomesubclassofjava.awt.AWTEventclass.ᫀDஹEQuestionNo5555.Gventhefollowingclassoutline:classExample{privateintx;//restofclassbodypublicstaticvoidmain(Stringargs[]){//implementationofmainmehtod})Whichstatementistrue?

60A.x=2isavalidassignmentinthemain()methodofclassExample.B.Changingprivateintxtointxwouldmakex=2avalidassignmentinthemain()methodofclassExample.C.Changingprivateintxtopublicintxwouldmakex=2avalidassignmentinthemain()methodofclassExample.D.Changingprivateintxtostaticintxwouldmakex=2avalidassignmentinthemain()methodofclassExample.E.ChangingclassExampletopublicclassExamplewouldmakex=2avalidassignmentinthemain()methodofclassExample.ᫀ:DQuestionNo5656.Whichstatementistrueaboutaninnerclass?A.ItmustbeanonymousB.ItcannotimplementaninterfaceC.ItisonlyaccessibleintheenclosingclassD.Itcanaccessanyfinalvariablesinanyenclosingscope.ᫀ:DQuestionNo5757.Whichstatementistrueaboutthegridbaglayoutmanager?A.Thenumberofrowsandcolumnsisfixedwhenthecontaineriscreated.B.ThenumberofrowsandcolumnsisfixedwhentheGridBagLayoutobjectiscreated.C.IfacomponenthasafillvalueofBOTH,thenasthecontainerchangesize,thecomponentisresized.D.Everycomponentmustcarryanon-zeroweightxandweightyvaluewhenitisaddedtothecontainerE.Ifarowhasaweightyvaluethatisnon-zero,thenasthecontainerchangesheight,therowchangesheight.ᫀ:C

61QuestionNo5858.Whichstatementaretrueaboutwritingaclassthatistohandletheeventsissuedbyauserinterfacecomponent.A.Subclassinganadapterisinappropriateinthiscase.B.TheclassshouldimplementsomelistenerinterfaceC.Aclasscanimplementmultiplelistenerinterfacesifdesired.D.AsubclassofanAWTcomponentcannotlistentoitsownevents.E.Whenimplementslistenerinterface,aclassneedonlyprovidethosehandlermethodsthatitchooses.ᫀBஹCQuestionNo5959.Theargumentforaclass?smain()methodiscalledargs,andtheclassisinvokedasfollows,javaExamplecatWhatwouldbetheeffectoftryingtoaccessargs[0]inthemainmethod?A.ThevalueproducediscatB.ThevalueproducedisjavaC.ThevalueproducedisExampleD.AnobjectoftypeNullFbinterExceptionisthrown.EAnobjectoftypeArraylndexQjtofBoundsExceptionisthrown.ᫀ:AQuestionNo6060.Whichbestdescribestherequirementsofafullyencapsulatedclass?A.Mehtodsmustnotbeprivate.B.Variablesmustnotbepublic.C.TheclassmustbemarkedfinalD.Publicmethodsareallmarkedfinal.EModificationoftheobjectsstateisonlypossibleusingmethodcalls.ᫀ:E

62QuestionNo6161.Whichcontainsobjectswithoutordering,duplication,oranyparticularlookup/retrievalmechanism?A.MapB.SetC.UstD.CollectionEEnumerationᫀ:Bscjp⚪()QuestionNo:11.Whichstatementaboutthegarbagecollectionmechanismaretrue?A.Garbagecollectionrequireadditionalprogram©codeincaseswheremultiplethreadsarerunning.B.Theprogrammercanindicatethatareferencethroughalocalvariableisnolongerofinterest.C.Theprogrammerhasamechanismthatexplicit/andimmediatelyfreesthememoryusedbyJavaobjects.D.ThegarbagecollectionmechanismcanfreethememoryusedbyJavaObjectatexplectiontime.E.Thegarbagecollectionsystemneverreclaimsmemoryfromobjectswhilearestillaccessibletorunninguserthreads.ᫀ:BஹEQuestionNo:22.Gvethefollowingmethod:1)publicvoidmethod(){2}Stringa,b;3}a=newString(uhelloworld");

634}b=newString(ugameover")5}System.out.println(a+b+nokH);6}a=null;7}a=b;8}System.out.println(a);9))Intheabsenceofcompileroptimization,whichistheearliestpointtheobjectareferedisdefinitelyelibiletobegarbagecollection.A.beforeline3B.beforeline5C.beforeline6D.beforeline7E.Beforeline9ᫀ:DQuestionNo:33.Intheclassjava.awt.AWTEvent,whichistheparentclassuponwhichjdk1.1awteventsarebasedthereisamethodcalledgetIDwhichphraseaccuratelydescribesthereturnvalueofthismethod?A.Itisareferencetotheobjectdirectlyaffectedbythecauseoftheevent.B.Itisanindicationofthenatureofthecauseoftheevent.C.Itisanindicationofthepositionofthemousewhenitcausedtheevent.D.Inthecaseofamouseclick,itisanindicationofthetextunderthemouseatthetimeoftheevent.EIttellsthestateofcertainkeysonthekeybordatthetimeoftheevent.F.Itisanindicationofthetimeatwhichtheeventoccurred.ᫀBQuestionNo:44.Whichstatementaboutlisteneristrue?A.Mostcomponentallowmultiplelistenerstobeadded.

64B.Ifmultiplelistenerbeaddtoasinglecomponent,theeventonlyaffectedonelistener.C.Componentdon?tallowmultiplelistenerstobeadd.D.ThelistenermechanismallowsyoutocallanaddXxxxListenermethodasmanytimesasisneeded,specifyingasmanydifferentlistenersasyourdesignrequire.ᫀAஹDQuestionNo:55.Gvethefollowingcode:publicclassExample{publicstaticvoidmain(Stringargs[]){int1=0;do{^stem.out.println(uDoingitforIis:"+l);}while(-l>0)^stem.out.println(,lFnishM);))Whichwellbeoutput:A.DoingitforIis3B.DoingitforIis1C.DoingitforIis2D.DoingitforIis0E.DoingitforIis?C1F.RnishᫀDஹFQuestionNo:66.Givethecodefragment:1)switch(x){2}case1:System.out.println(HTest1M);break;

653}case2:4}case3:System.out.println(HTest2M);break;5}default:System.out.printlnC'end");6))whichvalueofxwouldcause“Test2ntotheoutput:A.1B.2C.3D.defaultᫀB.CQuestionNo:77.Gveincompletedmethod:1)2){if(unsafe()){//dosomething..)3}elseif(safe()){//dotheother..)4})Themethodunsafe()wellthroeanlOException,whichcompletesthemethodofdeclarationwhenaddedatlineone?A.publiclOExceptionmethodName()B.publicvoidmethodName()C.publicvoidmethodName()throwlOExceptionD.publicvoidmethodName()throwslOExceptionEpublicvoidmethodName()throwsExceptionᫀDஹFQuestionNo:88.Givethecodefragment:if(x>4){System.out.println(KTest1");}

66elseif(x>9){^stem.out.println(uTest2");}else{^stem.out.println(uTest3");}WhichrangeofvaluexwouldproduceofoutputuTest2”A.x<4B.x>4C.x>9D.Noneᫀ:DQuestionNo:99.Gvethefollowingmethod:publicvoidexample(){try(unsafe();System.out.printlnCTestl");}catch(SafeExceptione){System.out.println("Test2")}finally{System.out.println(uTest3");}System.out.println(uTest4")Whichwilldisplayifmethodunsafe()runnormally?A.Test1B.Test2C.Test3D.Test4ᫀAஹCஹDQuestionNo:1010.Whichmethodyoudefineasthestartingpointofnewthreadinaclassfromwhichnewthethreadcanbeexcution?

67A.publicvoidstart()B.publicvoidrun()C.publicvoidint()D.publicstaticvoidmain(Stringargs[])E.publicvoidrunnable()ᫀ:BQuestionNo:1111.Giventhefollowingclassdefinition:classA{protectedinti;A(inti){this.i=i;))whichofthefollowingwouldbeavalidinnerclassforthisclass?Selectallvalidanswers:A.classB{)B.classBextendsA{)C.classBextendsA{B(){System.out.println(Mi=M+i);})D.classB{classA{})EclassA{}ᫀ:A

68QuestionNo:1212.Whichmodifiershouldbeappliedtoamethodforthelockofobjectthistobeobtainedpriortoexcutionanyofthemethodbody?A.synchronizedB.abstractC.finalD.staticE.publicᫀ:AQuestionNo:1313.ThefollowingcodeisentirecontentsofafilecalledExample.java,causespreciselyoneerrorduringcompilation:1)classSubClassextendsBaseQass{2))3)classBaseQass(){4}Stringstr;5}publicBaseClass(){6}System.out.println(uokn)}7}publicBaseaass(Strings){8}str=s;}}9)publicclassExample{10}publicvoidmethod(){11}SubQasss=newSubaass(,lhelloM);12}BaseQassb=newBaseaass(uworldn)13)}14))Whichlinewouldbecausetheerror?A.9B.10C.11D.12

69ᫀ:cQuestionNo:1414.Whichstatementiscorrectlydeclareavariableawhichissuitableforreferingtoanarrayof50stringemptyobject?A.String[]aB.Stringa[]C.chara[][]D.Stringa[50]F.Objecta[50]ᫀAஹBQuestionNo:1515.Gvethefollowingjavasourcefragement://pointxpublicclassInteresting(//dosomething)WhichstatementiscorrectlyJavasyntaxatpointx?A.importjava.awt.*;B.packagemypackageC.staticintPl=3.14D.publicclassMyQass{//dootherthing..}EclassMyClass{//dosomething..)ᫀAஹEQuestionNo:1616.Gvethisclassoutline:classExample{privateintx;//restofclassbody...

70AssumingthatxinvokedbythecodejavaExample,whichstatementcanmadexbedirectlyaccessibleinmain()methodofExample.java?A.ChangeprivateintxtopublicintxB.changeprivateintxtostaticintxC.ChangeprivateintxtoprotectedintxD.changeprivateintxtofinalintxᫀ:BQuestionNo:1717.thepieceofpreliminaryanalsisworkdescribesaclassthatwillbeusedfrequentlyinmanyunrelatedpartsofaprojectuThepolygonobjectisadrawable,Apolygonhasvertexinformationstoredinavector,acolor,lengthandwidth."WhichDatatypewouldbeused?A.VectorB.intC.StringD.ColorE.DateᫀAஹBஹDQuestionNo:1818.Aclassdesignrequiresthatamembervariableshouldbeaccessibleonlybysamepackage,whichmodiferwordshouldbeused?A.protectedB.publicC.nomodiferD.private

71ᫀ:cQuestionNo:1919.Whichdeclaresfornativemethodinajavaclasscorrected?A.publicnativevoidmethod(){}B.publicnativevoidmethod();C.publicnativemethod();D.publicvoidmethod(){native;}E.publicvoidnativemethod();ᫀ:BCXjestionNo:2020.Whichmodifershouldbeappliedtoadeclarationofaclassmembervariableforthevalueofvariabletoremainconstantafterthecreationoftheobject?ᫀfinalQuestionNo:2121.Whichisthemain()methodreturnofaapplication?A.StringB.byteC.charD.voidᫀ:DQuestionNo:2222.Whichiscorrectedargumentofmain()methodofapplication?A.StringargsB.Stringar[]

72C.Charargs[][]D.StringBufferarg[]ᫀ:BQuestionNo:2323.“TheEmployeeobjectisaperson,AnEmployeehasappointmentstoreinavector,ahiredateandanumberofdependent"shortanswer:useshorteststatementdeclareaclassofEmployee.ᫀpublicclassEmployeeextendsPersonQuestionNo:2424.Givethefollowingclassdefinationinseparatesourcefiles:publicclassExample{publicExample(){//dosomething}protectedExample(inti){//dosomething}protectedvoidmethod(){//dosomething})publicclassHelloextendsExample{//membermethodandmembervariable}WhichmethodsarecorrectedaddedtotheclassHello?A.publicvoidExample(){}B.publicvoidmethod(){}C.protectedvoidmethod(){}D.privatevoidmethod(){}ᫀAஹBஹCQuestionNo:2525.Roats=newRoat(0.9F);Floatt=newFloat(0.9F);Doubleu=newDouble(0.9);

73Whichexpression?sresultistrue?A.s==tB.s.equals(t)C.s==uD.t.equals(u)ᫀAஹBQuestionNo:2626.Givefollowingclass:classAQass{privatelongval;publicAQass(longv){val=v;}publicstaticvoidmain(Stringargs[]){AQassx=newAQass(1OL);ACIassy=newACIass(10L);AQassz=y;longa=10L;intb=10;))Whichexpressionresultistrue?A.a==b;B.a==x;C.y==z;D.x==y;E.a==10.0;ᫀAஹCஹE

74QuestionNo:2727.Asocketobjecthasbeencreatedandconnectedtoastandardinternetserviceonaremotenetworkserver.WhichconstructiongivethemostsuitablemeansforreadingASCIIdataonlineatatimefromthesocket?A.Inputstreamin=s.getlnputStream();B.DatalnputStreamin=newDatalnputstream(s.getlnputStream());C.ByteArraylnputStreamin=newByteArraylnputStream(s.getlnputStream());D.BufferedReaderin=newBufferedReader(newInputStreamReader(s.getInputStream()));E.BufferedReaderin=newBufferedReader(newInputStreamReader(s.getlnputStream()),,,8859-1H);ᫀ:EQuestionNo:2828.Strings="ExampleString”Whichoperationislegal?A.s>>>=3;B.inti=s.length();C.s[3]=,,x>>;D.Stringshort_s=s.trim();E.Stringt=nrootH+s;ᫀBஹDஹEQuestionNo:2929.Whathappenswhenyoutrytocompileandrunthefollowingprogram?classMystery{Strings;publicstaticvoidmain(String[]args){Mysterym=newMystery();m.go();

75voidMystery(){s="constructor";)voidgo(){System.out.println(s);))A.thiscodewillnotcompileB.thiscodecomplilesbutthrowsanexceptionatruntimeC.thiscoderunsbutnothingappearsinthestandardoutputD.thiscoderunsand"constructor"inthestandardoutputE.thiscoderunsandwrites“null"inthestandardoutputᫀ:EQuestionNo:3030.WhatusetopositionaButtoninaFrame,onlywidthofButtonisaffectedbytheFramesize,whichLayoutButtonwellbeset?A.FlowLayout;B.GridLayout;C.NorthofBorderLayoutD.SouthofBorderLayoutE.EastorWestofBorderLayoutᫀCஹDQuestionNo:3131.WhatusetopositionaButtoninaFrame,sizeofButtonisnotaffectedbytheFramesize,whichLayoutButtonwillbeset?A.FlowLayout;

76B.GridLayout;C.NorthofBorderLayoutD.SouthofBorderLayoutE.EastorWestofBorderLayoutᫀ:AQuestionNo:3232.AnAWTGUIunderexposurecondition,whichoneormoremethodwellbeinvokewhenitredraw?A.paint();B.update();C.repaint();D.drawing();ᫀ:AQuestionNo:3333.SelectvalididentifierofJava:A.userNameB.%passwdC.3d_gameD.$chargeE.thisᫀAஹDQuestionNo:3434.WhichareJavakeyword?A.gotoB.nullC.FALSE

77D.nativeE.constᫀAஹBஹDஹEQuestionNo:3535.Runacorrectedclass:java?CcsAOassabcWhichstatementistrue?A.args[0]=M-csM;B.args[1]=Mabc”C.args[O]=,,java5>;D.args[0]=HaM;E.args[1]=?b?ᫀ:DQuestionNo:3636.Givethefollowingjavaclass:publicclassExample{staticintx[]=newint[15];publicstaticvoidmain(Stringargs[]){^stem.out.println(x[5]);))Whichstatementiscorrected?A.Whencompile,someerrorwilloccur.B.Whenrun,someerrorwilloccur.C.CXitputiszero.D.Outputisnull.ᫀ:C

78QuestionNo:3737.Givethefollowingjavaclass:publicclassExample{publicstaticvoidmain(Stringargs[]){staticintx[]=newint[15];System.out.println(x[5]);))Whichstatementiscorrected?A.Whencompile,someerrorwilloccur.B.Whenrun,someerrorwilloccur.C.Outputiszero.D.Outputisnull.ᫀ:AQuestionNo:3838.Shortanswer:Thedecimalvalueofiis12,theoctalivalueis:ᫀ014QuestionNo:3939.Shortanswer:Thedecimalvalueofiis7,thehexadecimalivalueis:ᫀ0x7QuestionNo:4040.Whichistherangeofchar?A.27-27-1B.0-216-1

79C.0-216D.0-28ᫀ:BQuestionNo:4141.Whichistherangeofinttype?A.-216-216-1B.-231-231-1C.-232-232-1D.-264-264-1ᫀ:BQuestionNo:4242.Givethefollowingclass:publicclassExample{Stringstr=newString(“good”)charch[]={publicstaticvoidmain(Stringargs[]){Exampleex=newExample();ex.change(ex.str,ex.ch);^stem.out.println(ex.str+"and"+ex.ch);)publicvoidchange(Stringstr,charch[]){str=HtestokM;ch[0]=?g?))Whichistheoutput:A.goodandabcB.goodandgbc

80C.testokandabcD.testokandgbcᫀ:BQuestionNo:4343.WhichcodefragmentswouldcorrectlyidentifythenumberofargumentspassedviacommandlinetoaJavaapplication,excludethenameoftheclassthatisbeinginvoke.A.intcount=args.length;B.intcount=args.length-1;C.intcount=0;while(args[count]!=null)count++;D.intcount=0;while(!(args[count].equals(MM)))count++;ᫀ:AQuestionNo:4444.FilterOutputStreamistheparentclassforBufferedOutputStream,DataOutputStreamandPrintstream.WhichclassesarevalidargumentfortheconstructorofaFlterOutputStream?A.InputstreamB.OutputstreamC.FileD.RandomAccessFIeE.StreamTokenizerᫀ:BQuestionNo:4545.GivenaTextAreausingaproportionalpitchfontandconstructedlikethis:TextAreat=newTextArea(u12345",5,5);Whichstatementistrue?

81A.ThedisplayedwidthshowsexactlyfivecharactersoneeachlineunlessotherwiseconstrainedB.ThedisplayedheightisfivelinesunlessotherwiseconstrainedC.ThemaximumnumberofcharactersinalinewillbefiveD.TheuserwillbeabletoeditthecharacterstringE.Thedisplayedstringcanusemultiplefontsᫀ:BQuestionNo:4646.GivenaListusingaproportionalpitchfontandconstructedlikethis:Listl=newList(5,true);Whichstatementistrue?A.ThedisplayeditemexactlyfivelinesunlessotherwiseconstrainedB.Thedisplayeditemisfivelinesinit,butcandisplayedmorethanfiveItembyscrollC.Themaximumnumberofiteminalistwillbefive.D.Thelistismultiplemodeᫀ:BQuestionNo:4747.Giventhisskeletonofaclasscurrentlyunderconstruction:publicclassExample{intx,y,z;publicExample(inta,intb){//lotsofcomplexcomputationx=a;y=b;)publicExample(inta,intb,intc){//doeverythingthesameassingleargument//versionofconstructor//includingassignmentx=a,y=b,z=c

82Z=c;)Whatisthemostconcisewaytocodethe“doeverything..partoftheconstructortakingtwoarguments?Shortanswer:ᫀthis(a,b);QuestionNo:4848.Whichcorrectlycreateatwodimensionalarrayofintegers?A.inta[][]=newint[][];B.inta[10][10]=newint[][];C.inta[][]=newint[10][10];D.int[][]a=newint[10][10];E.int[]a[]=newint[10][10];ᫀCஹDஹEQuestionNo:4949.Whicharecorrectclassdeclarations?AssumeineachcasethatthetextconstitutestheentirecontentsofafilecalledFred.java?A.publicclassFred{publicintx=0;publicFred(intx){this.x=x;))B.publicclassfred{publicintx=0;publicFred(intx){

83this.x=x;)C.publicclassFredextendsMyBaseQass,MyOtherBaseQass{publicintx=0;publicFred(intxval){x=xval;))D.protectedclassFred{privateintx=0;privateFred(intxval){x=xval;))E.importjava.awt.*;publicclassFredextendsObject{intx;privateFred(intxval){x=xval;))ᫀAஹEQuestionNo:5050.Aclassdesignrequiresthataparticularmembervariablemustbeaccessiblefordirectaccessbyanysubclassesofthisclass.butotherwisenotbyclasseswhicharenotmembersofthesamepackage.Whatshouldbedonetoachievethis?A.Thevariableshouldbemarkedpublic

84B.ThevariableshouldbemarkedprivateC.ThevariableshouldbemarkedprotectedD.ThevariableshouldhavenospecialaccessmodifierE.ThevariableshouldbemarkedprivateandanaccessormethodprovidedᫀCQuestionNo:5151.Whatmightcausethecurrentthreadtostopexecuting?A.Aninterruptedexceptionisthrown.B.Thethreadexecuteasleep()call.C.ThethreadconstructsanewthreadD.AthreadofhigherprioritybecomesreadyEThethreadexecutesaread()callonInputstreamᫀAஹBஹDஹEQuestionNo:5252.Whichstatementsaretrueaboutthreads?A.Threadscreatedfromthesameclassallfinishtogether.B.Athreadcanbecreatedonlybysubclassingjava.lang.Thread.C.Invokingthesuspend()methodstopsathreadsothatitcannotberestarted.D.TheJavainterpreter?snaturalexitoccurswhennonon-daemonthreadsremainalive.E.Uncoordinatedchangestoshareddatabymultiplethreadsmayresultinthedatabeingread,orleft,inaninconsistentstate.ᫀDஹEQuestionNo:5353.Whatmightformpartofacorrectinnerclassdeclarationorcombineddeclarationandinstantiation?A.privateclassC

85B.newSmplelnterface(){C.newComplexlnterface(x){D.privatefinalabstractclass(EnewComplexQassOimplementsSmplelnterfaceᫀAஹBQuestionNo:5454.Whichstatementsaretrueaboutthegarbagecollectionmechanisms?A.Thegarbagecollectionmechanismreleasememoryatpridictabletimes.B.AcorrectprogrammustnotdependuponthetimingororderofgarbagecollectionC.GarbagecollectionensuresthataprogramwillNOTrunoutofmemoryduringexecutionD.Theprogrammercanindicatethatareferencethroughalocalvariableisnolongergoingtobeused.E.TheprogrammerhasamechanismthatexplicitlyandimmediatelyfreesthememoryusedbyJavaobjects.ᫀBஹDQuestionNo:5555.Gventhefollowing,4.Stringd="bookkeeper";5.d.substring(1,7);6.d="w”+d;7.d-appendCwoo**)8.System.out.println(d);whatistheresult?A.wookkeewooB.wbookkeeperC.wbookkeewooD.wbookkeeperwoo

86E.Compilationfails.F.Anexceptionisthrownatruntime.ᫀ:EQuestionNo:5656.Whichtwostatementsaretrueaboutcomparingtwoinstancesofthesameclass,giventhattheequals()andhashCode()methodshavebeenproperlyoverridden?(Choosetwo.)A.Iftheequals()methodreturnstrue,thehashCode()comparison==mustreturntrue.B.Iftheequals()methodreturnsfalse,thehashCode()comparison!=mustreturntrue.C.IfthehashCode()comparison==returnstrue,theequals()methodmustreturntrue.D.IfthehashCode()comparison==returnstrue,theequals()methodmightreturntrue.E.IfthehashCode()comparison!=returnstrue,theequals()methodmightreturntrue.ᫀ:AandDQuestionNo:5757.Gventhefollowing,1.classX2{2.publicX2x;3.publicstaticvoidmain(String[]args){4.X2x2=newX2();5.X2x3=newX2();6.x2.x=x3;7.x3.x=x2;8.x2=newX2();

879.x3=x2;10.doComplexStuff();11)12.)afterline9runs,howmanyobjectsareeligibleforgarbagecollection?A.0B.1C.2D.3E4ᫀ:CQuestionNo:5858.Whichtwoaretrueaboutamethod-localinnerclass?A.Itmustbemarkedfinal.B.Itcanbemarkedabstract.C.Itcanbemarkedpublic.D.Itcanbemarkedstatic.E.Itcanaccessprivatemembersoftheenclosingclass.ᫀ:AEQuestionNo:5959.Giventhefollowing,1.publicclassTestObj{2.publicstaticvoidmain(String[]args){3.Objecto=newObject(){4.publicbooleanequals(Objectobj){5.returntrue;6.}

887}8.System.out.println(o.equals(',Fred,'));9.}10.}whatistheresult?A.Anexceptionoccursatruntime.B.trueC.fredD.Compilationfailsbecauseofanerroronline3.ECompilationfailsbecauseofanerroronline4.F.Compilationfailsbecauseofanerroronline8.G.Compilationfailsbecauseofanerroronalineotherthan3,4,or8.ᫀ:GQuestionNo:6060.Gventhefollowing,1.classTest{2.3.publicstaticvoidmain(String[]args){4.printAII(args);5.}6.7.publicstaticvoidprintAll(String[]lines){8.for(inti=O;i

89thestaticmethodThread.currentThread()returnsareferencetothecurrentlyexecutingThreadobject.Whatistheresultofthiscode?A.EachStringinthearraylineswilloutput,witha1-secondpause.B.EachStringinthearraylineswilloutput,withnopauseinbetweenbecausethismethodisnotexecutedinaThread.C.EachStringinthearraylineswilloutput,andthereisnoguaranteetherewillbeapausebecausecurrentThread()maynotretrievethisthread.D.Thiscodewillnotcompile.ᫀ:DQuestionNo:6161.Whichtwoaretrue?A.ThenotifyAII()methodmustbecalledfromasynchronizedcontext.B.Tocallwait(),anobjectmustownthelockonthethread.C.Thenotify()methodisdefinedinclassjava.lang.Thread.D.Whenathreadiswaitingasaresultofwait(),itreleaseitslocks.EThenotify()methodcausesathreadtoimmediatelyreleaseitslocks.F.Thedifferencebetweennotify()andnotifyAII()isthatnotifyAII()notifiesallwaitingthreads,regardlessoftheobjectthey'rewaitingon.ᫀ:AD⚪1Choosethethreevalididentifiersfromthoselistedbelow.A.IDoLikeTheLongNameQassB.$byteC.constD._okE.3_caseA,B,D

90JavaḄ᪗!"#$%ஹ&ᐗ((ᡈ*ᑜ,(-ᜮ஺ᐵ0$12ᶇ$4567᪗஺⌱⚗CḄconst#JavaḄ2ᶇ$ᡠ;456᪗஺⌱⚗EḄ3_case;ᦪ$-ᜮ=>?JavaḄ@ᑣ஺⚪2Howcanyouforcegarbagecollectionofanobject?A.GarbagecollectioncannotbeforcedB.CallSystem.gc().C.CallSystem.gc(),passinginareferencetotheobjecttobegarbagecollected.D.CallRuntime.gc().E.Setallreferencestotheobjecttonewvalues(null,forexample).AᙠJavaᚗDᦈF#45GHIJᓽ᡻MḄ஺NᵨS/stem.gc()ᡈRuntime.gc஺☟᝱RS452TᚗDᦈFᘤḄJᓽ᡻MV7WXYᙠḼ[\]ᐜ_Ḅ,`஺ᡠ;⌱⚗BஹD4ab஺⌱⚗CḄ┯dᙠeSystem.gc஺RS#4fghᦪḄ஺⌱⚗EḄRSi;jklᙠ*•nᚗDᦈFopMqGᦈF஺⚪3Considerthefollowingclass:1.classTest(inti){2.voidtest(inti){3.System.out.println(Hlamanint.");4.}5.voidtest(Strings){6.System.out.println("lamastring.");7.}8.9.publicstaticvoidmain(Stringargs[]){10.Testt=newTest();11.charch='y

9112.t.test(ch);13.}14.}Whichofthestatementsbelowistrue?(Chooseone.)A.Line5wnotcompile,becausevoidmethodscannotbeoverridden.B.Line12willnotcompile,becausethereisnoversionoftest()thatrakesacharargument.C.Thecodewillcompilebutwillthrowanexceptionatline12.D.Thecodewillcompileandproducethefollowingoutput:Iamanint.E.Thecodewillcompileandproducethefollowingoutput:IamaString.Dᙠr12M16stḄcharuvwchᙠxyqz{|}ᓄ732stḄintu,ᙠpMqvoidtest(inti)RS஺⚪4Whichofthefollowinglinesofcodewillcompilewithouterror?A.inti=0;if(i){System.out.println("Hi");)B.booleanb=true;booleanb2=true;if(b==b2){^stem.out.println("Sotrue");)C.

92inti=1;intj=2;if(i==1||j==2)Wstem.out.println("OK');D.inti=1;intj=2;if(i==1&|j==2)^stem.out.println("OK');B,C⌱⚗A┯V7if◤⌕booleanuḄ⊤஺6ᨵஹ&ஹ|&&ஹ||,#”&|”#SḄᡠ;⌱⚗D4ab஺⚪5Whichtwodemonstratea"hasa"relationship?(Choosetwo)A.publicinterfacePerson{}publicclassEmployeeextendsPerson{}B.publicinterfaceShape{}publicinterfaceFtectandleextendsShape{}C.publicinterfaceColorable{}publicclassShapeimplementsColorable()D.publicclassSpecies{}publicclassAnimal{privateSpeciesspecies;}EinterfaceComponent{}classContainerimplementsComponent{privateComponentschildren;)D,EᙠJavaṹᵨᨵi5ḄRᓽᔠ(“hasa”ᐵ)¡¢“isa”ᐵ£ஹ“hasa”ᐵ#¤¥¦§Ḅ¨ឋḄRª«Ḅ;

93“isa”ᐵ#¤¥¡¢ª«Ḅ஺®⌱⚗AஹBஹC¯«?“isa”ᐵ⌱⚗DஹE¯«?“hasa”ᐵ஺[1][2]*⚓®²³ᑖᦻ¶ᦈFe·¸᱐ᩗ»¼6ὅ¾¿᱐Àᡠᨵ᝞ÂÃÄÅÆÇ?ÃḄ᱐ᩗÈᩭÊËÌᡃÎ,ᡃÎzÏÐᑤ◀ᐸᑁÕÖ®²¼×ᦻ¶᱐ᩗ»®²ᡠᨵ◀ᱯÙᵭÛ᜜ᜧÞi;{ᵫ}à¼6ὅᩭ{®²Ḅáf!"2ᶇÖ⚪6Whichtwostatementsaretruefortheclassjava.util.TreeSet?(Choosetwo)A.Theelementsinthecollectionareordered.B.Thecollectionisguaranteedtobeimmutable.C.Theelementsinthecollectionareguaranteedtobeunique.D.Theelementsinthecollectionareaccessedusingauniquekey.E.TheelementsinthecollectionareguaranteedtobesynchronizedA,CTreeSetª«?Setfâ஺SetḄᱯ#ᐸḄᐗãä⌱⚗Cab஺ᵫeåᵨ?᪛çYoRèᐗãᨵéᙢëìᩭᡠ;⌱⚗AWab஺⚪7TrueorFalse:Readershavemethodsthatcanreadandreturnfloatsanddoubles.A.TureB.FalseBReader/WriteríᜐᳮUnicode$Ḅðᐭð¿floatdoublei;¤¥streamòMI/O.⚪8Whatdoesthefollowingpaint()methoddraw?1.publicvoidpaint(Graphicsg){2.g.drawString("Anyquestion",10,0);

943.)A.Thestring"Anyquestion?1,withitstop-leftcornerat10,0B.Alittlesquigglecomingdownfromthetopofthecomponent.BdrawString(Stringstr,intx,inty)RS#jᵨóôḄõ⁐$èstrḄᑁÕ÷¿ᩭøᨬúḄ$Ḅû,ü(x,y)-ý஺ᙠ®⚪,y=0,ᡠ;û,seᨬ⚔ÿ஺ᡃᑮḄᑖᓽVஹ'q'Ḅᑖ஺⚪9Whathappenswhenyoutrytocompileandrunthefollowingapplication?Chooseallcorrectoptions.1.publicclassZ{2.publicstaticvoidmain(String[]args){3.newZ();4.}5.6.Z(){7.Zaliasl=this;8.Zalias2=this;9.synchronized(aliasl){10.try{11.alias2.wait();12.System.out.println(nDONEWAITING);13.}14.catch(InterruptedExceptione){15.System.out.println(*'lNTERRUPTED");16.)17.catch(Exceptione){18.System.out.println("OTHEREXCEFTION");

9519.}20.finally{21.System.out.printin("FINALLY");22.}23.}24.System.out.println(nALLDONE');25.}26.}A.Theapplicationcompilesbutdoesn"tprintanything.B.Theapplicationcompilesandprint"DONEWAITlNG'C.Theapplicationcompilesandprint"FINALLY"D.Theapplicationcompilesandprint"ALLDONE"E.Theapplicationcompilesandprint"INTERRUFTED',AᙠJava!ᨵ┝஺$%&᎛(┝!)*ᵫ,-.ᑴ஺ᵫ0aliasl1alias2ᢣᔣ4Z,ᙠ᡻6117,-8ᨵZḄ┝஺ᙠ᡻9611:;(,-<=>ZḄ┝?ᐭABC஺DE;Fᨵ,-GᵨZḄnotify()#nohfyAII()IJᡠ:(?-Lᜐ0ABN᝱FᨵPQ஺⚪10Whichstatementorstatementsaretrueaboutthecodelistedbelow?Choosethree.1.publicclassMyTextAreaextendsTextArea{2.publicMyTextArea(intnrows,intncols){3.enableEvents(AWTEvent.TEXT_EVENT_MASK);4}5.6.publicvoidprocessTextEvent

96(TextEventte){7.System.out.println("Processingatextevent.");8.}9}A.Thehttp://www.qd.sd.cncodemustappearinafilecalledMyTextArea.javaB.Betweenlines2and3,acallshouldbemadetosuper(nrows,ncols)sothatthenewcomponentwillhavethecorrectsize.C.Atline6,thereturntypeofprocessTextEvent()shouldbedeclaredboolean,notvoid.D.Betweenlines7and8,thefollowingcodeshouldappear:returntrue.E.Betweenlines7and8,thefollowingcodeshouldappear:super.processTextEvent(te).A,B,Eᵫ0RSpublic,ᡠ:ᦻUVWX1YZ⌱⚗A]^஺᝞`aᙠ2ஹ3Ybcdsuper(nrows,ncols)ḄeᑣgGᵨhiᦪ᪀lᘤTextArea஺nmowsஹncolsopqᜫᦑ⌱⚗B]^஺ᙠJava2ᡠᨵḄtUᜐᳮIJ!avwx⌱⚗CஹD┯z஺⌱⚗E]^{|᝞`a}~super.processTextEvent(te),Ḅlisteneragᖔ⏨஺

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。
最近更新
更多
大家都在看
近期热门
关闭