Java 认证模考试题.docx

上传人:b****3 文档编号:26405307 上传时间:2023-06-19 格式:DOCX 页数:41 大小:22.83KB
下载 相关 举报
Java 认证模考试题.docx_第1页
第1页 / 共41页
Java 认证模考试题.docx_第2页
第2页 / 共41页
Java 认证模考试题.docx_第3页
第3页 / 共41页
Java 认证模考试题.docx_第4页
第4页 / 共41页
Java 认证模考试题.docx_第5页
第5页 / 共41页
点击查看更多>>
下载资源
资源描述

Java 认证模考试题.docx

《Java 认证模考试题.docx》由会员分享,可在线阅读,更多相关《Java 认证模考试题.docx(41页珍藏版)》请在冰豆网上搜索。

Java 认证模考试题.docx

Java认证模考试题

Java 认证模考试题

[作者:

佚名  发表时间:

2004-5-2722:

14:

08  阅读:

331]

 

Java2TEST

Question:

1

Giventhefollowingcode:

classTest{

privateintm;

publicstaticvoidfun(){

//somecode...

}

}

Howcanthemembervariablembeaccessibledirectlyinthemethodfun()?

A.changeprivateintmtoprotectedintm

B.changeprivateintmtopublicintm

C.changeprivateintmtostaticintm

D.changeprivateintmtointm

Explanation:

Ifthevariablemischangedtobeastaticvariableitcanbeaccessibleinthemethodfun()forthismethodisastaticmembermethod.

CorrectAnswer:

C1of60

 

 

 

Question:

2

Whichmethodsarecorrectoverloadingmethodsofthefollowingmethod:

publicvoidexample(){...}

A.publicvoidexample(intm){...}

B.publicintexample(){...}

C.publicvoidexample2(){...}

D.publicintexample(intm,floatf){...}

Explanation:

Theoverloadingmethodsmusthavethesamenames.Ifonlythereturntypeofthemethodsaredifferentitissufficienttellthemethodsfromeachother.Theargumentsofthemethodsmustbedifferentenoughtodeterminewhichmethodtocall.

CorrectAnswer:

A,D2of60

 

 

 

Question:

3

Giventhefollowingfragmentofcode:

publicclassBase{

intw,x,y,z;

publicBase(inta,intb){

x=a;y=b;

}

publicBase(inta,intb,intc,intd){

//assignmentx=a,y=b

w=d;

z=c;

}

}

Whichexpressionscanbeusedatthepointof//assignmentx=a,y=b?

A.Base(a,b);

B.x=a,y=b;

C.x=a;y=b;

D.this(a,b);

Explanation:

Inthesecondconstructor,thecallthis(a,b)passescontroltheversionoftheconstructorthattakestwointarguments.

CorrectAnswer:

C,D3of60

 

 

 

Question:

4

Giventhefollowingdefinition:

Strings=story;

Whichofthefollowingexpressionsarelegal?

A.s+=books;

B.charc=s[1];

C.intlen=s.length;

D.Stringt=s.toLowerCase();

Explanation:

AnswerBisnotcorrectforStringisaclassandcan'Tbetreatedasanarrayofchar.AnswerCisnotcorrectfors.length()shouldbeused,nots.length.

CorrectAnswer:

A,D4of60

 

 

 

Question:

5

Whatisthereturnvalueofthemain()methodinJava?

A.String

B.int

C.char

D.void

Explanation:

Themain()methodinJavareturnsvoid.

CorrectAnswer:

D5of60

 

 

Question:

6

WhicharethevalididentifiersinJava?

A.fieldname

B.super

C.3number

D.#number

E.$number

Explanation:

ValididentifiersinJavacanstartwithaletter,underscore(_),ordollarsign($),butnotwithdigitsorothersigns.Andidentifierscannotbekeywords.

 

CorrectAnswer:

A,E6of60

 

 

Question:

7

WhicharevalidJavakeywords?

A.const

B.NULL

C.false

D.this

E.native

Explanation:

AllthekeywordsinJavaarelowercase.gotoandconstarekeywordsthatarenotusedinJavaprogramminglanguage.

CorrectAnswer:

A,C,D,E7of60

 

 

Question:

8

WhicharevalidintegralexpressionsinJava?

A.22

B.0x22

C.022

D.22H

Explanation:

InJavaintegralhasthreeforms:

decimal,octalandhexadecimal.Octalvaluesstartwithazeroandhexadecimalvaluesstartwith0x.

CorrectAnswer:

A,B,C8of60

 

 

Question:

9

Whichoneofthefollowingrangesofshortiscorrect?

 

 

Explanation:

Thelengthoftheshortdatais16bits.Therangeofshortis

Thelengthoftheshortdatais16bits.Therangeofshortis

CorrectAnswer:

D9of60

 

Question:

10

 Whichoneofthefollowingrangesofbyteiscorrect?

 

 

 

 

CorrectAnswer:

B10of60

 

Question:

11

Giventhefollowingfragmentofcode,whatareresultsofiandjafterexecution?

inti=1;

intj;

j=i++;

A.1,1

B.1,2

C.2,1

D.2,2

Explanation:

Payattentiontothepositionoftheoperator++.Inthisquestion,firstjisassignedto1,thenthevalueofiisaddedto2.

CorrectAnswer:

C11of60

 

 

 

Question:

12

Whichofthefollowingstatementsaretrue?

A.>>isthearithmeticrightshiftoperator.

B.>>isthelogicalrightshiftoperator.

C.>>>isthearithmeticrightshiftoperator.

D.>>>isthelogicalrightshiftoperator.

Explanation:

TherearetworightshiftoperatorsinJava.Theyare>>and>>>.>>isthearithmetic(signed)rightshiftoperatorand>>>isthelogical(unsigned)rightshiftoperator.

CorrectAnswer:

A,D12of60

 

 

 

Question:

13

Whichofthefollowingassignmentsarelegal?

A.floata=2.0

B.doubleb=2.0

C.intc=2

D.longd=2

Explanation:

InJavathedefaultdatatypeoffloatingpointisdouble,notfloat.Theassignmentfromdoubletofloatrequiresanexplicitcast.

CorrectAnswer:

B,C,D13of60

 

 

 

Question:

14

Whichoneofthefollowingargumentsisthecorrectargumentofthemain()method?

A.charargs[]

B.charargs[][]

C.Stringarg[]

D.Stringargs

Explanation:

Theargumentofthemain()methodisanarrayofString.ThenonlyanswerCisanarrayofString.

CorrectAnswer:

C14of60

 

 

 

 

Question:

15

Whichoneofthefollowingiscorrecttocreateanarray?

A.floatf[][]=newfloat[6][6];

B.float[]f[]=newfloat[6][6];

C.floatf[][]=newfloat[][6];

D.float[][]f=newfloat[6][6];

E.float[][]f=newfloat[6][];

Explanation:

InJavathedeclarationformatallowsthesquarebracketstobeattheleftorrightofthevariablename.Butthenewfloat[][6]isillegal.

CorrectAnswer:

A,B,D,E15of60

 

 

 

 

 

Question:

16

Giventhefollowingexpression:

intm[]={0,1,2,3,4,5,6};

Whichresultofthefollowingexpressionsequalstothenumberofthearrayelements?

A.m.length()

B.m.length

C.m.length()+1

D.m.length+1

Explanation:

Thenumberofelementsinanarrayisstoredinthelengthattributeinthearrayobject.

CorrectAnswer:

B16of60

 

Question:

17

Giventhefollowingcommandtorunacorrectclass:

javaMyTestabc

Whichstatementsaretrue?

A.args[0]=MyTestabc

B.args[0]=MyTest

C.args[0]=a

D.args[1]='b'

Explanation:

Thethreeargumentsabcarestoredintheargs[]arrayofthemain()method.Thenargs[0]=a,args[1]=b,args[2]=c.

CorrectAnswer:

C17of60

 

Question:

18

Giventhefollowingcode:

publicclassTest{

longa[]=newlong[10];

publicstaticvoidmain(Stringarg[]){

System.out.println(a[6]);

}

}

Whichstatementistrue?

A.Outputisnull.

B.Outputis0.

C.Whencompile,someerrorwilloccur.

D.Whenrunning,someerrorwilloccur.

Explanation:

Whenanarrayiscreatedthemembersofthearrayisinitialized.Inthiscasealltheelementsareinitializedtobe0.

CorrectAnswer:

B18of60

 

Question:

19

Giventhefollowingfragmentofcode:

booleanm=true;

if(m=false)

System.out.println(False);

else

System.out.println(True);

Whatistheresultoftheexecution?

A.False

B.True

C.None

D.Anerrorwilloccurwhenrunning.

Explanation:

=istheassignmentoperator.==isthecompareoperator.Inthisquestionthevalueoffalseisassignedtothevariablem.

CorrectAnswer:

A19of60

 

Question:

20

Giventhefollowingcode:

publicclassTest{

publicstaticvoidmain(Stringarg[]){

inti=5;

do{

System.out.println(i);

}while(--i>5)

System.out.println(“finished”);

}

}

Whatwillbeoutputafterexecution?

A.5

B.4

C.6

D.Finished

E.None

Explanation:

Theexpressionsintheblockofdo/whileloopwillbeexecutedatleastonce.Iftheconditionofthisloopisnotmettheloopwillstopafteronceexecution,otherwise,itwillcontinuetoloopuntiltheconditionisnomet.

CorrectAnswer:

A,D20of60

 

Question:

21

Whatwillbeoutputafterexecutionofthefollowingcode:

outer:

for(inti=0;i<3;i++)

inner:

for(intj=0;j<2;j++)

{

if(j==1)continueouter;

System.out.println(j+?

and?

+i);

}

A.0and0

B.0and1

C.0and2

D.1and0

E.1and1

F.1and2

G.2and0

H.2and1

I.2and2

Explanation:

Thecontinuestatementisusedtoskipoverandjumptotheendoftheloopbody.Thenifjequalsto1itwilljumptotheendoftheinnerloopbody.

CorrectAnswer:

A,B,C21of60

 

Question:

22

Giventhefollowingcode:

switch(m)

{

case0:

System.out.println(Condition0);

case1:

System.out.println(Condition1);

case2:

System.out.println(Condition2);

case3:

System.out.println(Condition3);break;

default:

System.out.println(OtherCondition);

}

WhichvaluesofmwillcauseCondition2isoutput?

A.0

B.1

C.2

D.3

E.4

F.None

Explanation:

Intheblockofswitch,ifthereisnobreaksentenceinonecasethefollowingsentenceswillbeexecuted.

CorrectAnswer:

A,B,C22of60

 

Question:

23

WhichmethodiscalledwhenthebrowserreturnstothepagecontainingtheappletaftermovingtoanotherURL?

A.init()

B.start()

C.stop()

D.destroy()

Explanation:

Thestart()runswhenevertheappletbecomesvisible,suchaswhenthebrowserreturnstothepagecontainingtheappletaftermovingtoanotherURLorthebrowserisrestoredafterbeingiconized.

CorrectAnswer:

B23of60

 

Question:

24

Ifathreadcallsthewait()method,whichmethodscanmakeitcontinuetorun?

A.join()

B.resume()

C.notify()

D.notifyAll()

E.highprioritythreadisready

Explanation:

Ifathreadissuesawait()callitwillpauseexecutionuntilanotherthreadissuesanotify()ornotifyAll()call.Thepairofthemethodsareprovidedforthreadcommunication.

CorrectAnswer:

C,D24of60

 

Question:

25

Whichmethodisusedtodefinetheexecutionbodyofathread?

A.start()

B.init()

C.run()

D.main()

E.synchronized()

Explanation:

Thethreadswillalwaysbeginexecutingattherun()method,whichcontainsthedef

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

当前位置:首页 > 高等教育 > 管理学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1