您好,欢迎访问三七文档
当前位置:首页 > 临时分类 > JAVA认证:147道SCJP考试试题精解
LeadingthewayinITtestingandcertificationtools,edu.yesky.comQuestionNo:1Given:1.publicclasstest(2.publicstaticvoidmain(Stringargs[]){3.inti=0xFFFFFFF1;4.intj=~i;5.6.}7.)Whatisthedecimalvalueofjatline5?A.0B.1C.14D.–15E.Anerroratline3causescompilationtofail.F.Anerroratline4causescompilationtofail.Answer:CQuestionNo:2Given: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))Answer: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=i10|methodB(4);11.b=i10||methodB(8);12.)13.14.publicstaticvoidmain(Stringargs[]}(15.methodA(0);16.system.out.printIn(j);17.)18.)Whatistheresult?A.Theprogramprints“0”B.Theprogramprints“4”C.Theprogramprints“8”D.Theprogramprints“12”E.Thecodedoesnotcomplete.Answer:BQuestionNo:4Given1.Publicclasstest(2.Publicstaticvoidmain(Stringargs[])(3.System.out.printIn(6^3);4.)5.)Whatistheoutput?Answer:5QuestionNo:5Given:1.publicclassFoo{2.publicstaticvoidmain(String[]args){3.StringBuffera=newStringBuffer(“A”);4.StringBufferb=newStringBuffer(“B”);5.operate(a,b);6.system.out.printIn{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”.C.Thecodecompilesandprints“B,B”.D.Thecodecompilesandprints“AB,B”.E.Thecodecompilesandprints“AB,AB”.F.Thecodedoesnotcompilebecause“+”cannotbeoverloadedforStringBuffer.Answer:DQuestionNo:6Exhibit:1.Publicclasstest(2.PublicstaticvoidstringReplace(Stringtext)(3.Text=text.replace(‘j',‘i');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?Answer:javajavaCQuestionNo: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.Compilationwillfail.B.Theprogramprints“0”.C.Theprogramprints“3”.D.Compilationwillsucceedbutanexceptionwillbethrownatline3.Answer:BQuestionNo:8Given:1.publicclassConstOver{2.publicConstOver(intx,inty,intz){3.}4.}WhichtwooverloadtheConstOverconstructor?(ChooseTwo)A.ConstOver(){}B.ProtectedintConstOver(){}C.PrivateConstOver(intz,inty,bytex){}D.PublicObjectConstOver(intx,inty,intz){}E.PublicvoidConstOver(bytex,bytey,bytez){}Answer:A,CQuestionNo:9Given:1.publicclassMethodOver{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;)E.ProtectedfloatsetVar(inta,intb,floatc)(returnc;)Answer:A,CQuestionNo:10Given:1.classBaseClass{2.Privatefloatx=1.0f;3.protectedfloatgetVar()(returnx;)4.}5.classSubclassextendsBaseClass(6.privatefloatx=2.0f;7.//insertcodehere8.)Whichtwoarevalidexamplesofmethodoverriding?(ChooseTwo)A.FloatgetVar(){returnx;}B.PublicfloatgetVar(){returnx;}C.FloatdoublegetVar(){returnx;}D.PublicfloatgetVar(){returnx;}E.PublicfloatgetVar(floatf){returnf;}Answer:B,DQuestionNo:11Whichtwodemonstratean“isa”relationship?(ChooseTwo)A.publicinterfacePerson{}publicclassEmployeeextendsPerson{}B.publicinterfaceShape{}publicclassEmployeeextendsShape{}C.publicinterfaceColor{}publicclassEmployeeextendsColor{}D.publicclassSpecies{}publicclassAnimal(privateSpeciesspecies;)E.interfaceComponent{}ClassContainerimplementsComponent(PrivateComponent[]children;)Answer:D,EQuestionNo:12Whichstatementistrue?A.Ananonymousinnerclassmaybedeclaredasfinal.B.Ananonymousinnerclasscanbedeclaredasprivate.C.Ananonymousinnerclasscanimplementmultipleinterfaces.D.Ananonymousinnerclasscanaccessfinalvariablesinanyenclosingscope.E.Constructionofaninstanceofastaticinnerclassrequiresaninstanceoftheenclosingouterclass.Answer:DQuestionNo13Given:1.packagefoo;2.3.publicclassOuter(4.publicstaticclassInner(5.)6.)Whichstatementistrue?A.AninstanceoftheInnerclasscanbeconstructedwith“newOuter.Inner()”B.Aninstanceoftheinnerclasscannotbeconstructedoutsideofpackagefoo.C.Aninstanceoftheinnerclasscanonlybeconstructedfromwithintheouterclass.D.Fromwithinthepackagebar,aninstanceoftheinnerclasscanbeconstructedwith“newinner()”Answer:AQuestionNo14Exhibit:1.publicclassenclosingone(2.publicclassinsideone{}3.)4.publicclassinertest(5.publicstaticvoidmain(string[]args)(6.enclosingoneeo=newenclosingone();7.//insertcodehere8.)9.)Whichstatementatline7constructsaninstanceoftheinnerclass?A.InsideOnewei=eo.newInsideOn();B.Eo.InsideOneei=eo.newInsideOne();C.InsideOneei=EnclosingOne.newInsideOn
本文标题:JAVA认证:147道SCJP考试试题精解
链接地址:https://www.777doc.com/doc-6499777 .html