資源描述:
《(SCJP)(JAVA)面試題》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
1、QuestionNo:11.publicclasstest(2.publicstaticvoidmain(Stringargs[]){3.inti=0xFFFFFFF1;4.intj=~i;5.6.}7.)Whatisthedecimalvalueofjatline5?A.0B.1C.14D.–15E.Anerroratline3causescompilationtofail.F.Anerroratline4causescompilationtofail.答案:(c)QuestionNo:2Given:Integeri=newInteger(42);Lo
2、ng1=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))答案:(f)QuestionNo:3Exhibit:1.publicclasstest(2.privatestaticintj=0;3.4.privatestaticbooleanmethodB(intk)(5.j+=k;6.returntrue;6
3、.)7.8.publicstaticvoidmethodA(inti){9.booleanb:10.b=i<10
4、methodB(4);11.b=i<10
5、
6、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“
7、12”E.Thecodedoesnotcomplete.答案:(b)QuestionNo:4Given1.Publicclasstest(2.Publicstaticvoidmain(Stringargs[])(3.System.out.printIn(6^3);4.)5.)Whatistheoutput?答案:(5)QuestionNo:5Given:1.publicclassFoo{2.publicstaticvoidmain(String[]args){3.StringBuffera=newStringBuffer(“A”);4.StringBuf
8、ferb=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.Thecodecompile
9、sandprints“AB,B”.E.Thecodecompilesandprints“AB,AB”.F.Thecodedoesnotcompilebecause“+”cannotbeoverloadedforStringBuffer.答案:(D)QuestionNo:6Exhibit:1.Publicclasstest(2.PublicstaticvoidstringReplace(Stringtext)(3.Text=text.replace(‘j’,‘i’);4.)5.6.publicstaticvoidbufferReplace(StringBu
10、ffertext)(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);1
11、8.)19.)Whatistheoutput?答案:(javajavaC)Que