一些SCJP考试题含答案Word格式.docx
- 文档编号:17539262
- 上传时间:2022-12-07
- 格式:DOCX
- 页数:28
- 大小:21.29KB
一些SCJP考试题含答案Word格式.docx
《一些SCJP考试题含答案Word格式.docx》由会员分享,可在线阅读,更多相关《一些SCJP考试题含答案Word格式.docx(28页珍藏版)》请在冰豆网上搜索。
D.Theprogramrunsbutabortswithanexception.
A
94
1.publicclassFoo{
2.publicstaticvoidmain(String[]args){
3.inti=1;
4.intj=i++;
5.if((i&
gt;
++j)&
amp;
&
(i++==j)){
6.i+=j;
Whatisthefinalvalueofi?
A.1
B.2
C.3
D.4
E.5
B
95
3.strings=newstring(“Hello”);
4.modify(s);
5.System.out.printIn(s);
6.}
7.
8.publicstaticvoidmodify(Strings){
9.s+=“world!
”;
10.}
11.}
E.Theprogramrunsandprints“Hello”
F.Anerrorcausescompilationtofail.
G.Theprogramrunsandprints“Helloworld!
”
H.Theprogramrunsbutabortswithanexception.
96
Whichtwoareequivalent?
(ChooseTwo)
A.16&
4
B.16/2
C.16*4
D.16&
2
E.16/2^2
F.16&
D,E
97
3.int[]a=newint[1]
4.modify(a);
5.System.out.printIn(a[0]);
8.publicstaticvoidmodify(int[]a){
9.a[0]++;
A.Theprogramrunsandprints“0”
B.Theprogramrunsandprints“1”
C.Theprogramrunsbutabortswithanexception.
D.Anerror“possibleundefinedvariable”atline4causescompilationtofail.
E.Anerror“possibleundefinedvariable”atline9causescompilationtofail.
98
13.publicclassFoo{
14.publicstaticvoidmain(String[]args){
15.StringBuffera=newStringBuffer(“A”);
16.StringBufferb=newStringBuffer(“B”);
17.operate(a,b);
18.system.out.printIn{a+“,”+b};
19.)
20.staticvoidoperate(StringBufferx,StringBuffery){
21.y.append{x};
22.y=x;
23.)
24.}
A.Thecodecompilesandprints“A,B”.
B.Thecodecompilesandprints“A,BA”.
C.Thecodecompilesandprints“AB,B”.
D.Thecodecompilesandprints“AB,AB”.
E.Thecodecompilesandprints“BA,BA”.
F.Thecodedoesnotcompilebecause“+”cannotbeoverloadedforstringBuffer.
99
2.publicstaticvoidmain(String[]args){
3.byteb=127;
4.bytec=126;
5.byted=b+c;
Whichstatementistrue?
A.Compilationsucceedsanddtakesthevalue253.
B.Line5containsanerrorthatpreventscompilation.
C.Line5throwsanexceptionindicating“Outofrange”
D.Line3and4containerrorthatpreventcompilation.
E.Thecompilationsucceedsanddtakesthevalueof1.
100
1.publicclassWhileFoo{
3.intx=1,y=6;
4.while(y--){x--;
}
5.system.out.printIn(“x=”+x“y=”+y);
A.Theoutputisx=6y=0
B.Theoutputisx=7y=0
C.Theoutputisx=6y=-1
D.Theoutputisx=7y=-1
E.Compilationwillfail.
E
101
A.TheErrorclassisauntimeException.
B.NoexceptionsaresubclassesofError.
C.AnystatementthatmaythrowanErrormustbeenclosedinatryblock.
D.AnystatementthatmaythrowanExceptionmustbeenclosedinatryblock.
E.AnystatementthatmaythroaruntimeExceptionmustbeenclosedinatryblock.
D
102
1.intI=1,j=0
2.
3.switch(i){
4.case2:
5.j+=6;
6.
7.case4:
8.j+=1;
9.
10.default:
11.j+=2;
12.
13.case0:
14.j+=4;
15.}
16.
Whatisthevalueofjatline16?
A.0
B.1
C.2
E.6
AE
103
1.switch(i){
2.default:
3.System.out.printIn(“Hello”);
4.)
Whatistheacceptabletypeforthevariablei?
A.Byte
B.Long
C.Float
D.Double
E.Object
F.AandB
G.CandD
104
Youneedtostoreelementsinacollectionthatguaranteesthatnoduplicatesarestored.Whichtwo
interfacesprovidethatcapability?
A.Java.util.Map
B.Java.util.Set
C.Java.util.List
D.Java.util.StoredSet
E.Java.util.StoredMap
F.Java.util.Collection
B,D
105
Whichstatementistruefortheclassjava.util.ArrayList?
A.Theelementsinthecollectionareordered.
B.Thecollectionisguaranteedtobeimmutable.
C.Theelementsinthecollectionareguaranteedtobeunique.
D.Theelementsinthecollectionareaccessedusingauniquekey.
E.Theelementsinthecollectionsareguaranteedtobesynchronized.
106
1.publicclassXimplementsRunnable(
2.privateintx;
3.privateinty;
4.
5.publicstaticvoidmain(String[]args)
6.Xthat=newX();
7.(newThread(that)).start();
8.(newThread(that)).start();
9.)
10.
11.publicvoidrun()(
12.for(;
;
)(
13.x++;
14.y++;
15.System.out.printIn(“x=”+x+“,y=”+y);
16.)
17.)
18.)
A.Errorsatlines7and8causecompilationtofail.
B.Theprogramprintspairsofvaluesforxandythatmightnotalwaysbethesameonthesameline
(forexample,“x=2,y=1”).
C.Theprogramprintspairsofvaluesforxandythatarealwaysthesameonthesameline(for
example,“x=1,y=1”.Inaddition,eachvalueappearstwice(forexample,“x=1,y=1”followedby
“x=1,y=1”).
D.Theprogramprintspairsofvaluesforxandythatarealwaysthesameonthesameline(for
example,“x=1,y=1”.Inaddition,eachvalueappearsonlyforonce(forexample,“x=1,y=1”
followedby“x=2,y=2”).
107
1.publicclassSyncTest{
4.publicsynchronizedvoidsetX(inti)(x=1;
)
5.publicsynchronizedvoidsetY(inti)(y=1;
6.publicsynchronizedvoidsetXY(int1)(setX(i);
setY(i);
7.publicsynchronizedBooleancheck()(returnx!
=y;
8.)
Underwhichconditionswillcheck()returntruewhencalledfromadifferentclass?
A.Check()canneverreturntrue.
B.Check()canreturntruewhensetXYiscalledbymultiplethreads.
C.Check()canreturntruewhenmultiplethreadscallsetXandsetYseparately.
D.Check()canonlyreturntrueifSyncTestischangedtoallowxandytobesetseparately.
108
WhichisamethodoftheMouseMotionListenerinterface?
A.PublicvoidmouseDragged(MouseEvent)
B.PublicbooleanmouseDragged(MouseEvent)
C.PublicvoidmouseDragged(MouseMotionEvent)
D.PublicbooleanMouseDragged(MouseMotionEvent)
E.PublicbooleanmouseDragged(MouseMotionEvent)
109
1.Stringfoo=“base”;
2.foo.substring(0,3);
3.foo.concat(“ket”);
4.foo+=“ball”;
5.
Typethevalueoffooatline8.
BASEBALL
QUESTIONNO110
1.publicclassTest{
2.publicstaticvoidleftshift(inti,intj){
3.i&
lt;
=j;
4.}
5.publicstaticvoidmain(Stringargs[]){
6.inti=4,j=2;
7.leftshift(i,j);
8.System.out.printIn(i);
A.2
B.4
C.8
D.16
E.Thecodewillnotcompile.
QUESTIONNO111
2.privateintval;
3.publicfoo(intv)(val=v;
)}
4.publicstaticvoidmain(String[]args){
5.Fooa=newFoo(10);
6.Foob=newFoo(10);
7.Fooc=a;
8.intd=10;
9.doublee=10.0;
Whichthreelogicalexpressionevaluatetotrue?
(ChooseThree)
A.(a==c)
B.(d==e)
C.(b==d)
D.(a==b)
E.(b==c)
F.(d==10.0)
A,B,F
QUESTIONNO112
2.privatestaticinta;
3.
5.publicstaticvoidmain(String[]args){
6.modify(a);
8.
9.publicstaticvoidmodify(inta){
10.a++;
12.}
D.Enerror“possibleundefinedvariable”atline5causescompilationtofail.
F.Enerror“possibleundefinedvariable”atline10causescompilationtofail.
QUESTIONNO113
2.publicstaticvoidreplaceJ(stringtext){
3.text.replace(‘j’,‘l’);
6.publicstaticvoidmain(Stringargs[]){
7.stringtext=newString(“java”)
8.replaceJ(text);
9.system.out.printIn(text);
A.Theprogramprints“lava”
B.Theprogramprints“java”
C.Anerroratline7causescompilationtofail.
D.Compilationsucceedsbuttheprogramthrowsanexception.
QUESTIONNO114
A.3/2
B.3&
C.3*4
D.3&
E.3*2^2
F.3&
C,D
QUESTIONNO115
Whatisthenumericalrangeofachar?
A.0...32767
B.0...65535
C.?
256...255
D.?
32768...32767
E.Rangeisplatformdependent.
QUESTIONNO116
3.unsignedbyteb=0;
4.b--;
Whatisthevalueofbatline5?
A.-1
B.255
C.127
D.Compilationwillfail.
E.Compilationwi
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 一些 SCJP 考试题 答案
![提示](https://static.bdocx.com/images/bang_tan.gif)