SCJP认证考试历年真题1_第1页
SCJP认证考试历年真题1_第2页
SCJP认证考试历年真题1_第3页
SCJP认证考试历年真题1_第4页
SCJP认证考试历年真题1_第5页
已阅读5页,还剩60页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

SCJP认证考试历年真题

我在网上见到很多关于SCJP考试的说法,很多人说他简单!

确实是这样的!但是这种说法只是当你拿到拿仅有的一套题

的时候,你可以这样说!有人说他考的相当全面,确实是这样

的,当你看到这一两百套题给你的时候,你就会有此感悟!呵

呵!头晕啊!它考的好多地方都是你在看资料的时候不留心

的地方你得不时的翻箱倒柜的找资料!这第2套题有147道

题,你可以将它收集起来!当你留心看的时候,你的心就宛如

一团乱麻,天那,这考的什么?想学真本事,就静下心,仔细研

究吧!!!这是19-50题!

310-025

LeadingthewayinITtestingandcertificationtools,

www.testking.com

QuestionNo19

Given:

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.

Answer:D

QuestionNo20

Given:

1.publicclasstest(

2.publicstaticvoidmain(string[]args){

3.stringfoo=args[1];

4.stringfoo=args[2];

5.stringfoo=args[3];

6.)

7.)

Andcommandlineinvocation:

JavaTestredgreenblue

Whatistheresult?

A.Bazhasthevalueof””

B.Bazhasthevalueofnul1

C.Bazhasthevalueof"red"

D.Bazhasthevalueof"blue"

E.Baxhasthevalueof“green”

F.Thecodedoesnotcompile.

G.Theprogramthrowsanexception.

Answer:G

QuestionNo21

Given:

8.intindex=1;

9.int[]foo=newint[3];

10.intbar=foo[index];

11.intbaz=bar+index;

Whatistheresult?

A.Bazhasthevalueof0

B.Bazhasthevalueof1

C.Bazhasthevalueof2

D.Anexceptionisthrown.

E.Thecodewillnotcompile.

Answer:B

QuestionNo22

Given:

1.publicclassfoo{

2.publiestaticvoidmain(String[]args)

3.Strings;

4.system.out.printin("s="+s);

5.}

6.)

Whatistheresult?

A.Thecodecompilesand“s=”isprinted.

B.Thecodecompilesand“s=null”isprinted.

C.Thecodedoesnotcompilebecausestringsisnot

initialized.

D.Thecodedoesnotcompilebecausestringscannot

bereferenced.

E.Thecodecompiles,butaNullPointerExceptionis

thrownwhentoStringiscalled.

Answer:C

QuestionNo23

Whichwilldeclareamethodthatforcesasubclassto

implementit?

A.PublicdoublemethodaO;

B.Staticvoidmethoda(doubledl){}

C.PublicnativedoublemethodaO;

D.AbstractpublicvoidmethodaO;

E.Protectedvoidmethoda(doubledl){}

Answer:D

QuestionNo24

Youwantsubclassesinanypackagetohaveaccessto

membersofasuperclass.Whichisthemost

restrictiveaccessmodifierthatwillaccomplishthis

objective?

A.Public

B.Private

C.Protected

D.Transient

E.Noaccessmodifierisqualified

Answer:C

QuestionNo25

Given:

1.abstractclassabstrctlt{

2.abstractfloatgetFloat();

3.)

4.publicclassAbstractTestextendsAbstractlt{

5.privatefloatfl=1.Of;

6.privatefloatgetFloat(){returnfl;}

7.)

Whatistheresult?

A.Compilationissuccessful.

B.Anerroronline6causesaruntimefailure.

C.Anerroratline6causescompilationtofail.

D.Anerroratline2causescompilationtofail.

Answer:C

QuestionNo26

Exhibit:

1.publicclasstest(

2.publicintaMethod()[

3.staticinti=0;

4.i++;

5.returnI;

6.)

7.publiestaticvoidmain(Stringargs[]){

8.testtest=newtest();

9.test.aMethod();

10.intj=test.aMethod();

11.System,out.printin(j);

12.]

13.}

Whatistheresult?

A.Compilationwillfail.

B.Compilationwillsucceedandtheprogramwillprint

ar\”

C.Compilationwillsucceedandtheprogramwillprint

“],,

D.Compilationwillsucceedandtheprogramwillprint

“2”

Answer:D

QuestionNo27

Given:

1.classsuper{

2.publicfloatgetNumO{return3.Of;}

3.)

4.

5.publieclassSubextendsSuper{

6.

7.)

Whichmethod,placedatline6,willcauseacompiler

error?

A.PublicfloatgetNumO{return4.Of;}

B.PublicvoidgetNum(){}

C.PublicvoidgetNum(doubled){}

D.PublicdoublegetNum(floatd){retrun4.Of;}

Answer:B

QuestionNo28

Whichdeclarationpreventscreatingasubclassofan

outerclass?

A.StaticclassFooBar{}

B.PrivateclassFooBar{}

C.AbstractpublicclassFooBar{}

D.FinalpublicclassFooBar{}

E.FinalabstractclassFooBar{}

Answer:D

QuestionNo29

Given:

1.byte口arryl,array2[];

2.bytearray3[]口;

3.byte[][]array4;

Ifeacharrayhasbeeninitialized,whichstatement

willcauseacompilererror?

A.Array2=array1;

B.Array2:array3;

C.Array2=array4;

D.BothAandB

E.BothAandC

F.BothBandC

Answer:F

QuestionNo30

Exhibit:

1.classsuper(

2.publieint1=0;

3.

4.publicsuper(stringtext)(

5.I=1

6.)

7.)

8.

9.publicclasssubextendssuper(

10.publicsub(stringtext)(

11.i=2

12.)

13.

14.publicstaticvoidmain(straingargs[])(

15.subsub=newsub("Hello");

16.system,out.Printin(sub.i);

17.)

18.)

Whatistheresult?

A.Compilationwillfail.

B.Compilationwillsucceedandtheprogramwillprint

“0”

C.Compilationwillsucceedandtheprogramwillprint

a],,

D.Compilationwillsucceedandtheprogramwillprint

“2”

Answer:A

QuestionNo31

Given:

1.publicclassreturnlt(

2.returnTypemethodA(bytex,doubley)(

3.return(short)x/y*2;

4.)

5.)

WhatisthevalidreturnTypeformethodAinline2?

A.Int

B.Byte

C.Long

D.Short

E.Float

F.Double

Answer:F

QuestionNo32

GiventheActionEvent,whichmethodallowsyouto

identifytheaffectedcomponent?

A.GetClass.

B.GetTarget.

C.GetSource.

D.GetComponent.

E.GetTargetComponent.

Answer:C

QuestionNo33

WhichisamethodoftheMouseMotionListenerinterface?

A.PublicvoidmouseMoved(MouseEvent)

B.PublicbooleanmouseMoved(MouseEvent)

C.PublicvoidmouseMoved(MouseMotionEvent)

D.PublicbooleanMouseMoved(MouseMotionEvent)

E.PublicbooleanmouseMoved(MouseMotionEvent)

Answer:A

QuestionNo34

Exhibit:

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.Panelpl=newpanel();

14.Add(pl);

15.Buttonbl=newButton(“One”);

16.Pl.add(bl);

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.Allthebuttonschangeheightiftheframeheight

isresized.

B.AllthebuttonschangewidthiftheFramewidthis

resized.

C.Thesizeofthebuttonlabeled"One”isconstant

eveniftheFrameisresized.

D.Bothwidthandheightofthebuttonlabeled“Three”

mightchangeiftheFrameisresized.

Answer:C,D

QuestionNo35

Youareassignedthetaskofbuildingapanelcontaining

aTextAreaatthetop,alabeldirectlybelowit,

andabuttondirectlybelowthelabel.Ifthethree

componentsareaddeddirectlytothepanel.Which

layoutmanagercanthepanelusetoensurethatthe

TextAreaabsorbsallofthefreeverticalspacewhen

thepanelisresized?

A.GridLayout.

B.CardLayout.

C.FlowLayout.

D.BorderLayout.

E.GridBagLayout.

Answer:E

QuestionNo36

Whichgetsthenameoftheparentdirectoryfile

“file,txt”?

A.Stringname=File.getParentName("file.txt");

B.Stringname=(newFile("file.txt")).getParent();

C.Stringname=(new

File(“file,txt")).getParentName();

D.Stringname二(new

File("file,txt")).getParentFile();

E.Directorydir=(newFile

(file,txtv)).getParentDir();

Stringname=dir.getName();

Answer:B

QuestionNo37

WhichcanbeusedtoencodecharSforoutput?

A.Java.io.Outputstream.

B.Java.io.OutputStreamWriter.

C.Java.io.EncodeOutputStream.

D.Java.io.EncodeWriter.

E.Java.io.BufferedOutputStream.

Answer:B

QuestionNo38

Thefile“file.txt“existsonthefilesystemand

contsinsASCIItext.

Given:

38.try{

39.Filef=newFile("file.txt");

40.OutputStreamout-newFileOutputStream(f,true);

41.)

42.catch(lOException){}

Whatistheresult?

A.Thecodedoesnotcompile.

B.Thecoderunsandnochangeismadetothefile.

C.Thecoderunsandsetsthelengthofthefileto0.

D.Anexceptionisthrownbecausethefileisnotclosed.

E.Thecoderunsanddeletesthefilefromthefile

system.

Answer:A

QuestionNo39

WhichconstructsaDataOutputStream?

A.NewdataOutputStream("out.txt");

B.NewdataOutputStream(newfile("out.txt"));

C.NewdataOutputStream(newwriter("out.txt"));

D.NewdataOutputStream(newFileWriter("out.txt"));

E.NewdataOutputStream(new

OutputStream("out.txt"));

F.NewdataOutputStream(new

FileOutputStream("out.txt"));

Answer:F

QuestionNo40

Whatwritesthetext""totheendofthefile

“file,txt”?

A.OutputStreamout=newFileOutputStream

(“file,txt");

Out.writeBytes("/n”);

B.OutputStreamos=newFileOutputStream("file.txt”

true);

DataOutputStreamout=newDataOutputStream(os);

out.writeBytes("/n");

C.OutputStreamos=newFileOutputStream

("file,txt");

DataOutputStreamout=newDataOutputStream(os);

out.writeBytes("/n”);

D.OutputStreamos=newOutputStream("file.txt”,

true);

DataOutputStreamout=newDataOutputStream(os);

out.writeBytes("/n");

Answer:B

QuestionNo41

Given:

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,eligible

forgarbagecollection?

A.Justafterline5

B.Justafterline6

C.Justafterline7(thatis,asthemethodreturns)

D.Neverinthismethod.

Answer:D

QuestionNo42

Given:

3.stringfoo="ABCDE”;

4.foo.substring(3);

5.foo.concat("XYZ”);

6.

Typethevalueoffooatline6.

Answer:ABCDE

QuestionNo43

Whichmethodisanappropriatewaytodeterminethe

cosineof42degrees?

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));

Answer:C

QuestionNo44

Youneedtostoreelementsinacollectionthat

guaranteesthatnoduplicatesarestoredandall

elements

canbeaccessedinnaturalorder.Whichinterface

providesthatcapability?

A.Java.util.Map.

B.Java.util.Set.

C.Java.util.List.

D.Java.util.StoredSet.

E.Java.util.StoredMap.

F.Java.util.Collection.

Answer:D

QuestionNo45

Whichstatementistruefortheclassjava.util.HashSet?

A.Theelementsinthecollectionareordered.

B.Thecollectionisguaranteedtobeimmutable.

C.Theelementsinthecollectionareguaranteedtobe

unique.

D.Theelementsinthecollectionareaccessedusing

auniquekey.

E.Theelementsinthecollectionsareguaranteedto

besynchronized.

Answer:C

QuestionNo46

Given:

1.publicclassIfTest(

2.publicstaticvoidmain(string[]args){

3.intx=3;

4.inty=1;

5.if(x=y)

6.system,out.println("Notequal");

7.else

8.system.out.printin("Equal");

9.)

10.)

Whatistheresult?

A.Theoutputis“Equal”

B.Theoutputin“NotEqual"

C.Anerroratline5causescompilationtofall.

D.Theprogramexecutesbutdoesnotprintamessage.

Answer:C

QuestionNo47

Exhibit:

1.publicclasstest(

2.publicstaticvoidmain(stringargs[])

3.int1=0;

4.while(i){

5.if(i==4){

6.break;

7.)

8.++i;

9.)

10.

11.)

12.)

Whatisthevalueofiat1ine10?

A.0

B.3

C.4

D.5

E.Thecodewillnotcompile.

Answer:E

QuestionNo48

Given:

3.inti=1,j=10;

4.do(

5.if(i++>-j)continue;

6.)while(i<5);

Afterexecution,whatarethevaluesforIandj?

A.i=6andj=5

B.i=5andj=5

C.i=6andj=4

D.i=5andj=6

E.i=6andj=6

Answer:D

QuestionNo49

Given:

1.switch(i){

2.default:

310-025

LeadingthewayinITtestingandcertificationtools,

www.testking.com

-27-

3.System,out.printin("Hello”);

4.)

Whatarethetwoacceptabletypesforthevariablei?

(ChooseTwo)

A.Char

B.Byte

C.Float

D.Double

E.Object

Answer:A,B

QuestionNo50

Given:

1.publicclassfoo{

2.publicstaticvoidmain(string[]args)

3.try{return;}

4.finally{system.out.println(^Finallyv);)

5.}

6.)

Whatistheresult?

A.Theprogramrunsandprintsnothing.

B.Theprogramrunsandprints“Finally”

C.Thecodecompiles,butanexceptionisthrownat

runtime.

D.Thecodewillnotcompilebecausethecatchblock

ismissing.

Answer:B

310-025

LeadingthewayinITtestingandcertificationtools,

QUESTIONNO:92

Given:

1.Stringfoo="blue”;

2.Boolean[]bar=newBoolean[1];

3.if(bar[0]){

4.foo="green”;

5.)

Whatistheresult?

A.Foohasthevalueofa

B.Foohasthevalueofnull.

C.Foohasthevalueof“blue”

D.Foohasthevalueof“green”

E.Anexceptionisthrown.

F.Thecodewillnotcompile.

Answer:F

QUESTIONNO:93

Exhibit:

1.publicclassX{

2.publicstaticvoidmain(String[]args){

3.Stringsi=newString("true");

4.Booleanbl=newBoolean(true);

5.if(s2.equals(bl)){

6.System.out.printin("Equal");

7.)

8.}

9.)

Whatistheresult?

A.Theprogramrunsandprintsnothing.

B.Theprogramrunsandprints“Equal”

C.Anerroratline5causescompilationtofail.

D.Theprogramrunsbutabortswithanexception.

Answer:A

QUESTIONNO:94

Given:

1.publicclassFoo{

2.publicstaticvoidmain(String[]args){

3.inti=1;

4.intj=i++;

5.if((i>++j)&&(i++=j)){

6.i+=j;

7.)

8.)

9.)

Whatisthefinalvalueofi?

A.1

B.2

C.3

D.4

E.5

Answer:B

QUESTIONNO:95

Exhibit:

1.publicclassX{

2.publicstaticvoidmain(String[]args)

3.strings=newstring("Heno”);

4.modify(s);

5.System,out.printin(s);

6.)

7.

8.publiestaticvoidmodify(Strings){

9.s+=“world!”;

10.}

11.)

Whatistheresult?

E.Theprogramrunsandprints“Hello”

F.Anerrorcausescompi1ationtofail.

G.Theprogramrunsandprints“Helloworld!”

H.Theprogramrunsbutabortswithanexception.

Answer:A

QUESTIONNO:96

Whichtwoareequivalent?(ChooseTwo)

A.16>4

B.16/2

C.16*4

D.16»2

E.16/2"2

F.16»>2

Answer:D,F

QUESTIONNO:97

Exhibit:

1.publicclassX{

2.publicstaticvoidmain(String[]args){

3.int□a=newint[1]

4.modify(a);

5.System.out.printin(a[0]);

6.)

7.

8.publicstaticvoidmodify(int[]a){

9.a[0]++;

10.}

11.}

Whatistheresult?

A.Theprogramrunsandprints“0”

B.Theprogramrunsandprints"1”

C.Theprogramrunsbutabortswithanexception.

D.Anerrorupossibleundefinedvariablevatline4

causescompilationtofail.

E.Anerrorupossibleundefinedvariablevatline9

causescompilationtofail.

Answer:B

QUESTIONNO:98

Given:

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,StringBuffer

y){

21.y.append{x};

22.y=x;

23.)

24.}

Whatistheresult?

A.Thecodecompilesandprints“A,B”.

B.Thecodecompilesandprints“A,BA”.

C.Thecodecompilesandprints“AB,B”.

D.Thecodecompilesandprints“AB,AB”.

E.Thecodecompilesandprints“BA,BA”.

F.Thecodedoesnotcompilebecause“+”cannotbe

overloadedforStringBuffer.

Answer:B

QUESTIONNO:99

Given:

1.publicclassX{

2.publicstaticvoidmain(String口args){

3.byteb=127;

4.bytec=126;

5.byted=b+c;

6.)

7.)

Whichstatementistrue?

A.Compilationsucceedsanddtakesthevalue253.

B.Line5containsanerrorthatpreventscompilation.

C.Line5throwsanexceptionindicating“Outof

range”

D.Line3and4containerrorthatpreventcompilation.

E.Thecompilationsucceedsanddtakesthevalueof

1.

Answer:B

QUESTIONNO:100

Given:

1.publicclassWhileFoo{

2.publiestaticvoidmain(String[]args){

3.intx=1,y=6;

4.while(y一){x一;}

5.system.out.printin("x="+x"y="+y);

6.)

7.)

Whatistheresult?

A.Theoutputisx=6y=0

B.Theoutputisx=7y=0

C.Theoutputisx=6y=-1

D.Theoutputisx=7y=-1

E.Compilationwillfail.

Answer:E

QUESTIONNO:101

Whichstatementistrue?

A.TheErrorclassisauntimeException.

B.NoexceptionsaresubclassesofError.

C.AnystatementthatmaythrowanErrormustbe

enclosedinatryblock.

D.AnystatementthatmaythrowanExceptionmustbe

enclosedinatryblock.

E.AnystatementthatmaythroaruntimeExceptionmust

beenclosedinatryblock.

Answer:D

QUESTIONNO:102

Exhibit:

1.int1=1,j=0

2.

3.switch(i){

4.case2:

5.j+=6;

6.

7.case4:

8.j+=l;

9.

10.default:

11.j+=2;

12.

13.case0:

14.j+=4;

15.}

16.

Whatisthevalueofjat1ine16?

A.0

B.1

C.2

D.4

E.6

Answer:AE

QUESTIONNO:103

Given:

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

Answer:A

QUESTIONNO:104

Youneedtostoreelementsinacollectionthat

guaranteesthatnoduplicatesarestored.Whichtwo

interfacesprovidethatcapability?(ChooseTwo)

A.Java.util.Map

B.Java.util.Set

C.Java.util.List

D.Java.util.StoredSet

E.Java.util.StoredMap

F.Java.util.Collection

Answer:B,D

QUESTIONNO:105

Whichstatementistruefortheclass

java.util.ArrayList?

A.Theelementsinthecollectionareordered.

B.Thecollectionisguaranteedtobeimmutable.

C.Theelementsinthecollectionareguaranteedtobe

unique.

D.Theelementsinthecollectionareaccessedusing

auniquekey.

E.Theelementsinthecollectionsareguaranteedto

besynchronized.

Answer:A

QUESTIONNO:106

Exhibit:

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.)

Whatistheresult?

A.Errorsatlines7and8causecompilationtofail.

B.Theprogramprintspairsofvaluesforxandythat

mightnotalwaysbethesameonthesameline

(forexample,"x=2,y=1").

C.Theprogramprintspairsofvaluesforxandythat

arealwaysthesameonthesameline(for

example,"x=l,y=l”.Inaddition,eachvalueappears

twice(forexample,"x=l,y=l"followedby

“x=l,y=l").

D.Theprogramprintspairsofvaluesforxandythat

arealwaysthesameonthesameline(for

example,"x=l,y=l”.Inaddition,eachvalueappears

onlyforonce(forexample,"x=l,y=1"

followedby“x=2,y=2").

Answer:D

QUESTIONNO:107

Given:

1.publicclassSyncTest{

2.privateintx;

3.privateinty;

4.publicsynchronizedvoidsetX(inti)(x=l;)

5.publicsynchronizedvoidsetY(inti)(y=l;)

6.publicsynchronizedvoidsetXY(int1)(setX(i);

setY⑴;)

7.publicsynchronizedBooleancheck()(returnx!=y;)

8.)

Underwhichconditionswillcheck()returntruewhen

calledfromadifferentclass?

A.Check()canneverreturntrue.

B.Check()canreturntruewhensetXYiscalledby

multiplethreads.

C.Check()canreturntruewhenmultiplethreadscall

setXandsetYseparately.

D.Check()canonlyreturntrueifSyncTestischanged

toallowxandytobesetseparately.

Answer:A

QUESTIONNO:108

WhichisamethodoftheMouseMotionListenerinterface?

A.PublicvoidmouseDragged(MouseEvent)

B.PublicbooleanmouseDragged(MouseEvent)

C.PublicvoidmouseDragged(MouseMotionEvent)

D.PublicbooleanMouseDragged(MouseMotionEvent)

E.PublicbooleanmouseDragged(MouseMotionEvent)

Answer:A

QUESTIONNO:109

Given:

1.Stringfoo="base”;

2.foo.substring(0,3);

3.foo.concat("ket”);

4.foo+="ball”;

5.

Typethevalueoffooatline8.

Answer:BASEBALL

QUESTIONNO110

Given:

1.publicclassTest{

2.publicstaticvoidleftshift(inti,intj)

3.i«=j;

4.)

5.publicstaticvoidmain(Stringargs[]){

6.inti=4,j=2;

7.leftshift(i,j);

8.System,out.printin(i);

9.}

10.}

Whatistheresult?

A.2

B.4

C.8

D.16

E.Thecodewillnotcompile.

Answer:B

QUESTIONNO111

Given:

1.publieclassFoo{

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;

10.}

11.)

Whichthreelogicalexpressionevaluatetotrue?

(ChooseThree)

A.(a==c)

B.(d==e)

C.(b==d)

D.(a==b)

E.(b==c)

F.(d==10.0)

Answer:A,B,F

QUESTIONNO112

Exhibit:

1.publicclassX{

2.privatestaticinta;

3.

5.publicstaticvoidmain(String口args){

6.modify(a);

7.)

8.

9.publicstaticvoidmodify(inta){

10.a++;

11.)

12.}

Whatistheresult?

A.Theprogramrunsandprints“0”

B.Theprogramrunsandprints"1”

C.Theprogramrunsbutabortswithanexception.

D.Enerror“possibleundefinedvariablenatline5

causescompilationtofail.

F.Enerror“possibleundefinedvariable“atline10

causescompilationtofail.

Answer:A

QUESTIONNO113

Exhibit:

1.publicclassTest{

2.publicstaticvoidreplacej(stringtext){

3.text,replace(4F);

4.}

5.

6.publicstaticvoidmain(Stringargs[]){

7.stringtext=newString("java”)

8.replacej(text);

9.system,out.printin(text);

10.}

11.)

Whatistheresult?

A.Theprogramprints"lava”

B.Theprogramprints“java”

C.Anerroratline7causescompilationtofail.

D.Compilationsucceedsbuttheprogramthrowsan

exception.

Answer:B

QUESTIONNO114

Whichtwoareequivalent?(ChooseTwo)

A.3/2

B.3<2

C.3*4

D.3«2

E.3*2-2

F.3«<2

Answer:C,D

QUESTIONNO115

Whatisthenumericalrangeofachar?

A.0...32767

B.0...65535

C.-256...255

D.-32768...32767

E.Rangeisplatformdependent.

Answer:B

QUESTIONNO116

Given:

1.publicclassTest{

2.publiestaticvoidmain(String[]args){

3.unsignedbyteb=0;

4.b一;

5.

6.)

7.)

Whatisthevalueofbat1ine5?

A.-1

B.255

C.127

D.Compilationwillfail.

E.Compilationwillsucceedbuttheprogramwillthrow

anexceptionatline4.

Answer:D

QUESTIONNO117

Given:

1.publicclassFoo{

2.publicvoidmain(String[]args){

3.system.out.println(uHelloWorld.n;

4.}

5.}

Whatistheresult?

A.Anexceptionisthrown.

B.Thecodedoesnocompile.

C."HelloWorld."Isprintedtotheterminal.

D.Theprogramexitswithoutprintinganything.

Answer:A

QUESTIONNO118

Given:

1.//pointX

2.publicclassfoo(

3.publicstaticvoidmain(String[]args)throws

Exception{

4.java.io.printWriterout=newjava.io.PrintWriter

(

5.newjava.io.outputStreamWriter(System,out),true;

6.out.printin(^Hellov);

7.)

8.}

WhichstatementatPointXonline1allowsthiscode

tocompileandrun?

A.Importjava.io.*;

B.Includejava.io.

C.Importjava.io.PrintWriter;

D.Includejava.io.PrintWriter;

E.Nostatementisneeded.

Answer:E

QUESTIONNO119

Whichwilldeclareamethodthatisavailabletoall

membersofthesamepackageandcanbereferenced

withoutaninstanceoftheclass?

A.Abstractpublicvoidmethoda();

B.Publicabstractdoublemethoda();

C.Staticvoidmethoda(doubledl){}

D.Publicnativedoublemethoda(){}

E.Protectedvoidmethoda(doubledl){}

Answer:C

QUESTIONNO120

Whichtypeofeventindicatesakeypressedona

java.awt.Component?

A.KeyEvent

B.KeyDownEvent

C.KeyPressEvent

D.KeyTypedEvent

E.KeyPressedEvent

Answer:A

QUESTIONNO121

Exhibit:

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(newBordrLayout());

12.Panelp=newPanel();

13.add(p,BorderLayout.NORTH);

14.Buttonb=newButton("North");

15.p.add(b):

16.Buttonb=newButton("South");

17.add(bl,BorderLayout.SOUTH):

18.}

19.}

Whichtwostatementsaretrue?(ChooseTwo)

A.Thebuttonslabeled“North”and"South”will

havethesamewidth.

B.Thebuttonslabeled“North”and"South"will

havethesameheight.

C.Theheightofthebuttonlabeled“North“canvery

iftheFrameisresized.

D.Theheightofthebuttonlabeled“South”canvery

iftheFrameisresized.

E.Thewidthofthebuttonlabeled“North“isconstant

eveniftheFrameisresized.

F.Thewidthofthebuttonlabeled“South“isconstant

eveniftheFrameisresized.

Answer:B,E

QUESTIONNO122

Howcanyoucreatealistenerclassthatreceivesevents

whenthemouseismoved?

A.ByextendingMouseListener.

B.ByimplementingMouseListener.

C.ByextendingMouseMotionListener.

D.ByimplementingMouseMotionListener.

E.EitherbyextendingMouseMotionListener

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论