Java程序员认证考试244题.docx

上传人:b****3 文档编号:10260877 上传时间:2023-05-24 格式:DOCX 页数:181 大小:925.03KB
下载 相关 举报
Java程序员认证考试244题.docx_第1页
第1页 / 共181页
Java程序员认证考试244题.docx_第2页
第2页 / 共181页
Java程序员认证考试244题.docx_第3页
第3页 / 共181页
Java程序员认证考试244题.docx_第4页
第4页 / 共181页
Java程序员认证考试244题.docx_第5页
第5页 / 共181页
Java程序员认证考试244题.docx_第6页
第6页 / 共181页
Java程序员认证考试244题.docx_第7页
第7页 / 共181页
Java程序员认证考试244题.docx_第8页
第8页 / 共181页
Java程序员认证考试244题.docx_第9页
第9页 / 共181页
Java程序员认证考试244题.docx_第10页
第10页 / 共181页
Java程序员认证考试244题.docx_第11页
第11页 / 共181页
Java程序员认证考试244题.docx_第12页
第12页 / 共181页
Java程序员认证考试244题.docx_第13页
第13页 / 共181页
Java程序员认证考试244题.docx_第14页
第14页 / 共181页
Java程序员认证考试244题.docx_第15页
第15页 / 共181页
Java程序员认证考试244题.docx_第16页
第16页 / 共181页
Java程序员认证考试244题.docx_第17页
第17页 / 共181页
Java程序员认证考试244题.docx_第18页
第18页 / 共181页
Java程序员认证考试244题.docx_第19页
第19页 / 共181页
Java程序员认证考试244题.docx_第20页
第20页 / 共181页
亲,该文档总共181页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

Java程序员认证考试244题.docx

《Java程序员认证考试244题.docx》由会员分享,可在线阅读,更多相关《Java程序员认证考试244题.docx(181页珍藏版)》请在冰点文库上搜索。

Java程序员认证考试244题.docx

Java程序员认证考试244题

第1題

Given:

35.String#name="JaneDoe";

36.int$age=24;

37.Double_height=123.5;

38.double~temp=37.5;

Whichtwostatementsaretrue?

(Choosetwo.)

A.Line35willnotcompile.

B.Line36willnotcompile.

C.Line37willnotcompile.

D.Line38willnotcompile.

第2題

Given:

1.publicclassTestString1{

2.publicstaticvoidmain(String[]args){

3.Stringstr="420";

4.str+=42;

5.System.out.print(str);

6.}

7.}

Whatistheoutput?

A.42

B.420

C.462

D.42042

E.Compilationfails.

F.Anexceptionisthrownatruntime.

第3題

Given:

1.publicclassTest{

2.publicstaticvoidmain(String[]args){

3.intx=5;

4.booleanb1=true;

5.booleanb2=false;

6.

7.if((x==4)&&!

b2)

8.System.out.print("1");

9.System.out.print("2");

10.if((b2=true)&&b1)

11.System.out.print("3");

12.}

13.}

Whatistheresult?

A.2

B.3

C.12

D.23

E.123

F.Compilationfails.

G.Anexceptionisthrownatruntime.

第4題

Given:

22.publicvoidgo(){

23.Stringo="";

24.z:

25.for(intx=0;x<3;x++){

26.for(inty=0;y<2;y++){

27.if(x==1)break;

28.if(x==2&&y==1)breakz;

29.o=o+x+y;

30.}

31.}

32.System.out.println(o);

33.}

Whatistheresultwhenthego()methodisinvoked?

A.00

B.0001

C.000120

D.00012021

E.Compilationfails.

F.Anexceptionisthrownatruntime.

第5題

Given:

10.intx=0;

11.inty=10;

12.do{

13.y--;

14.++x;

15.}while(x<5);

16.System.out.print(x+","+y);

Whatistheresult?

A.5,6

B.5,5

C.6,5

D.6,6

第6題

Given:

1.publicclassBreaker{

2.staticStringo="";

3.publicstaticvoidmain(String[]args){

4.z:

5.o=o+2;

6.for(intx=3;x<8;x++){

7.if(x==4)break;

8.if(x==6)breakz;

9.o=o+x;

10.}

11.System.out.println(o);

12.}

13.}

Whatistheresult?

A.23

B.234

C.235

D.2345

E.2357

F.23457

G.Compilationfails.

第7題

Given:

1.publicclassBreaker2{

2.staticStringo="";

3.publicstaticvoidmain(String[]args){

4.z:

5.for(intx=2;x<7;x++){

6.if(x==3)continue;

7.if(x==5)breakz;

8.o=o+x;

9.}

10.System.out.println(o);

11.}

12.}

Whatistheresult?

A.2

B.24

C.234

D.246

E.2346

F.Compilationfails.

第8題

Given:

1.publicclassSpock{

2.publicstaticvoidmain(String[]args){

3.Longtail=2000L;

4.Longdistance=1999L;

5.Longstory=1000L;

6.if((tail>distance)^((story*2)==tail))

7.System.out.print("1");

8.if((distance+1!

=tail)^((story*2)==distance))

9.System.out.print("2");

10.}

11.}

Whatistheresult?

A.1

B.2

C.12

D.Compilationfails.

E.Nooutputisproduced.

F.Anexceptionisthrownatruntime.

第9題

Given:

11.String[]elements={"for","tea","too"};

12.Stringfirst=(elements.length>0)?

elements[0]:

null;

Whatistheresult?

A.Compilationfails.

B.Anexceptionisthrownatruntime.

C.Thevariablefirstissettonull.

D.Thevariablefirstissettoelements[0].

第10題

Given:

1.importjava.util.*;

2.publicclassQuest{

3.publicstaticvoidmain(String[]args){

4.String[]colors=

5.{"blue","red","green","yellow","orange"};

6.Arrays.sort(colors);

7.ints2=Arrays.binarySearch(colors,"orange");

8.ints3=Arrays.binarySearch(colors,"violet");

9.System.out.print(s2+""+s3);

10.}

11.}

Whatistheresult?

A.2-1

B.2-4

C.2-5

D.3-1

E.3-4

F.3-5

G.Compilationfails.

H.Anexceptionisthrownatruntime.

第11題

Given:

1.classAlligator{

2.publicstaticvoidmain(String[]args){

3.int[]x[]={{1,2},{3,4,5},{6,7,8,9}};

4.int[][]y=x;

5.System.out.print(y[2][1]);

6.}

7.}

Whatistheresult?

A.2

B.3

C.4

D.6

E.7

F.Compilationfails.

第12題

DragandDrop(拖曳題)

AddmethodstotheBetaclasstomakeitcompilecorrectly.

classAlpha{

publicvoidbar(int...x){}

publicvoidbar(intx){}

}

publicclassBetaextendsAlpha{

Placehere

Placehere

Placehere

}

第13題

Given:

1.publicclassBarn{

2.publicstaticvoidmain(String[]args){

privatevoidbar(intx){}

publicvoidbar(intx){}

publicintbar(Stringx){return1;}

publicAlphabar(intx){}

publicvoidbar(intx,inty){}

publicintbar(intx){returnx;}

Methods

3.newBarn.go("hi",1);

4.newBarn.go("hi","world",2);

5.}

6.publicvoidgo(String...y,intx){

7.System.out.print(y[y.length-1]+"");

8.}

9.}

Whatistheresult?

A.hihi

B.hiworld

C.worldworld

D.Compilationfails.

E.Anexceptionisthrownatruntime.

第14題

Given:

11.classPerson{

12.Stringname="Noname";

13.publicPerson(Stringnm){name=nm;}

14.}

15.

16.classEmployeeextendsPerson{

17.StringempID="0000";

18.publicEmployee(Stringid){empID=id;}

19.}

20.

21.classEmployeeTest{

22.publicstaticvoidmain(String[]args){

23.Employeee=newEmployee("4321");

24.System.out.println(e.empID);

25.}

26.}

Whatistheresult?

A.4321

B.0000

C.Anexceptionisthrownatruntime.

D.Compilationfailsbecauseofanerrorinline18.

第15題

Given:

11.classMud{

12.//insertcodehere

13.System.out.println("hi");

14.}

15.}

Andthefollowingfivefragments:

publicstaticvoidmain(String...a){

publicstaticvoidmain(String.*a){

publicstaticvoidmain(String...a){

publicstaticvoidmain(String[]...a){

publicstaticvoidmain(String...[]a){

Howmanyofthecodefragments,insertedindependentlyatline12,compile?

A.0

B.1

C.2

D.3

E.4

F.5

第16題

Given:

5.classAtom{

6.Atom(){System.out.print("atom");}

7.}

8.classRockextendsAtom{

9.Rock(Stringtype){System.out.print(type);}

10.}

11.publicclassMountainextendsRock{

12.Mountain(){

13.super("granite");

14.newRock("granite");

15.}

16.publicstaticvoidmain(String[]a){newMountain();}

17.}

Whatistheresult?

A.Compilationfails.

B.atomgranite

C.granitegranite

D.atomgranitegranite

E.Anexceptionisthrownatruntime.

F.atomgraniteatomgranite

第17題

Given:

1.publicclassBlip{

2.protectedintblipvert(intx){return0;}

3.}

4.classVertextendsBlip{

5.//insertcodehere

6.}

Whichfivemethods,insertedindependentlyatline5,willcompile?

(Choosefive.)

A.publicintblipvert(intx){return0;}

B.privateintblipvert(intx){return0;}

C.privateintblipvert(longx){return0;}

D.protectedlongblipvert(intx){return0;}

E.protectedintblipvert(longx){return0;}

F.protectedlongblipvert(longx){return0;}

G.protectedlongblipvert(intx,inty){return0;}

第18題

Given:

1.classSuper{

2.privateinta;

3.protectedSuper(inta){this.a=a;}

4.}

...

11.classSubextendsSuper{

12.publicSub(inta){super(a);}

13.publicSub(){this.a=5;}

14.}

Whichtwo,independently,willallowSubtocompile?

(Choosetwo.)

A.Changeline2to:

publicinta;

B.Changeline2to:

protectedinta;

C.Changeline13to:

publicSub(){this(5);}

D.Changeline13to:

publicSub(){super(5);}

E.Changeline13to:

publicSub(){super(a);}

第19題

WhichManclassproperlyrepresentstherelationship"ManhasabestfriendwhoisaDog"?

A.classManextendsDog{}

B.classManimplementsDog{}

C.classMan{privateBestFrienddog;}

D.classMan{privateDogbestFriend;}

E.classMan{privateDog;}

F.classMan{privateBestFriend;}

第20題

AteamofprogrammersisreviewingaproposedAPIforanewutilityclass.Aftersomediscussion,they

realizethattheycanreducethenumberofmethodsintheAPIwithoutlosinganyfunctionality.Ifthey

implementthenewdesign,whichtwoOOprincipleswilltheybepromoting?

A.Loosercoupling

B.Tightercoupling

C.Lowercohesion

D.Highercohesion

E.Weakerencapsulation

F.Strongerencapsulation

第21題

Given:

1.classBatman{

2.intsquares=81;

3.publicstaticvoidmain(String[]args){

4.newBatman().go();

5.}

6.voidgo(){

7.incr(++squares);

8.System.out.println(squares);

9.}

10.voidincr(intsquares){squares+=10;}

11.}

Whatistheresult?

A.81

B.82

C.91

D.92

E.Compilationfails.

F.Anexceptionisthrownatruntime.

第22題

Given:

1.classPass{

2.publicstaticvoidmain(String[]args){

3.intx=5;

4.Passp=newPass();

5.p.doStuff(x);

6.System.out.print("mainx="+x);

7.}

8.voiddoStuff(intx){

9.System.out.println("doStuffx="+x++);

10.}

11.}

Whatistheresult?

A.Compilationfails.

B.Anexceptionisthrownatruntime.

C.doStuffx=6mainx=6

D.doStuffx=5mainx=5

E.doStuffx=5mainx=6

F.doStuffx=6mainx=5

第23題

Acompanyhasabusinessapplicationthatprovidesitsuserswithmanydifferentreports:

receivablesreports,payablesreports,revenueprojects,andsoon.Thecompanyhasjustpurchasedsomenew,state-of-the-art,wirelessprinters,andaprogrammerhasbeenassignedthetaskofenhancingallofthereportstousenotonlythecompany'soldprinters,butthenewwirelessprintersaswell.Whentheprogrammerstartslookingintotheapplication,theprogrammerdiscoversthatbecauseofthedesignoftheapplication,itisnecessarytomakechangestoeachreporttosupportthenewprinters.

Whichtwodesignconceptsmostlikelyexplainthesituation?

(Choosetwo.)

A.Inheritance

B.Lowcohesion

C.Tightcoupling

D.Highcohesion

E.Loosecoupling

F.Objectimmutablility

第24題

AcompanythatmakesComputerAssistedDesign(CAD)softwarehas,withinitsapplicationsomeutilityclassesthatareusedtoperform3Drenderingtasks.Thecompany'schiefscientisthasjustimprovedtheperformanceofoneoftheutilityclasses'keyrenderingalgorithms,

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 求职职场 > 简历

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2