Java英文题2.docx

上传人:b****3 文档编号:5331483 上传时间:2022-12-15 格式:DOCX 页数:48 大小:51.47KB
下载 相关 举报
Java英文题2.docx_第1页
第1页 / 共48页
Java英文题2.docx_第2页
第2页 / 共48页
Java英文题2.docx_第3页
第3页 / 共48页
Java英文题2.docx_第4页
第4页 / 共48页
Java英文题2.docx_第5页
第5页 / 共48页
点击查看更多>>
下载资源
资源描述

Java英文题2.docx

《Java英文题2.docx》由会员分享,可在线阅读,更多相关《Java英文题2.docx(48页珍藏版)》请在冰豆网上搜索。

Java英文题2.docx

Java英文题2

Multiple-Choice

1.ThenameofaJavasourcefiled

(a)hasnorestrictions

(b)mustbethesameastheclassitdefines,ignoringcase

(c)mustusetheextension.class

(d)mustbethesameastheclassitdefines,respectingcase

2.Whichofthefollowingstatementsis(are)trueabouttheuseofanasterisk(*)inaJavaimportstatement?

b

Ⅰ.Itdoesnotincurrun-timeoverhead.

Ⅱ.Itcanbeusedtoimportmultiplepackageswithasinglestatement.

Ⅲ.Itcanbeusedtoimportmultipleclasseswithasinglestatement

(a)I,II,andIII(b)IandIIIonly(c)Ionly(d)IIIonly

3.Whatisthenameofthewrapperclassforthetypeint?

c

(a)INT(b)integer(c)Integer(d)Int

4.Adifferencebetweenthemethodsprintandprintlnoftheclassjava.io.PrintWriteristhatd

(a)printlninsertsanewlineatthebeginningofitsoutput,butprintdoesnot

(b)printinsertsanewlineatthebeginningofitsoutput,butprintlndoesnot

(c)printappendsanewlinetotheendofitsoutput,butprintlndoesnot

(d)printlnappendsanewlinetotheendofitsoutput,butprintdoesnot

5.ConsiderthefollowingJavaprogramsegment.a

intx=5;inty=2;

System.out.println(x+"1"+y);

Whichofthefollowingstatementsistrueabouttheprogramsegment?

(a)Theoutputcausedbythecodewillbe512.

(b)Theoutputcausedbythecodewillbe512.

(c)Theoutputcausedbythecodewillbe8.

(d)Thecodewillcauseacompilationerror.

6.AllJavaexceptionclassesarederivedfromtheclassb

(a)java.lang.RuntimeException

(b)java.lang.Throwable

(c)java.lang.Error

(d)java.io.IOException

7.WhatistherightwaytohandleabnormalitiesininputonJava?

b

(a)Bywritingwhileloopstoguardagainstbadinput

(b)Byhandlingtheseproblemsbyprovidingexceptionhandlers

(c)ByusingtheclassFileFilterwhichgracefullyfiltersoutbadinputdata

(d)ByalwaysspecifyingthethrowsclauseineverymethodheaderwherefileI/Oisperformed

8.WhichofthefollowingpatternsofcharactersopensaJavadoccommentblock?

c

(a)/*(b)**/(c)/**(d)//

9.AccordingtotheJavacodeconventions,filesthatcontainJavasourcecodehavethesuffix_____,andcompiledbytecodefileshavethesuffix_____.c

(a).class,.java(b).class,.javac

(c).java,.class(d).javac,.class

10.AsanaidindebuggingaprograminJava,printstatementsmaybeusedtodisplaywhichofthefollowingtypesofinformation?

d

I.Thenamesofmethodsbeingcalled

II.Thevaluesoftheparametersofamethod

Ⅲ.Thevaluesoftheinstancevariablesofaclass

(a)IandIIonly(b)IandIIIonly

(c)IIandIIIonly(d)I,II,andIII

1.InaUMLclassdiagram'srepresentationofaclass,thetop,middle,andlowerrectangularcompartmentsrespectivelydescribethe_____oftheclass.a

(a)name,attributes,andmethods(b)name,methods,andconstants

(c)attributes,methods,andname(d)attributes,methods,andconstants

2.UMLclassdiagramscandescribewhichofthefollowing?

a

I.Theinternalstructureofclasses

Ⅱ.Relationshipsbetweenclasses

(a)IandII(b)IIonly(c)None(d)Ionly

3.ConsiderthefollowingUMLclassdiagram.b

Accordingtothediagram,instancesoftheclassnamed_____havereferencestoinstancesoftheclassnamed_____.b

(a)B,A(b)A,C(c)B,C(d)A,B

4.WhichofthefollowingistrueaboutassociationandaggregationinUMLclassdiagrams?

b

(a)Associationistheoppositeofaggregation.

(b)Aggregationisaspecialformofassociation.

(c)Associationisaspecialformofaggregation.

(d)Associationandaggregationhavenomeaningfulrelationship.

?

?

5.Abinaryassociationissaidtoexistbetweentwoclasseswhenb

(a)oneclassbelongstothesamepackageastheotherclass

(b)anobjectofoneclassrequiresanobjectoftheotherclass

(c)anobjectofoneclassisinstantiatedinthesamemethodasanobjectoftheotherclass

(d)oneclassisasubtypeoftheotherclass

6.ConsiderthefollowingUMLclassdiagram.

Accordingtothediagram,whichofthefollowingstatementsis(are)true?

c

I.ClassBisaspecializationofClassA.

II.ClassAisageneralizationofClassC.

Ⅲ.ClassCisinvolvedinaself-containmentloop.

(a)IIandIIIonly(b)IandIIonly

(c)I,II,andIII(d)IandIIIonly

7.Acollectiontypicallymodelsa_____relationship.d

(a)one-to-one(b)many-to-many(c)zero-to-one(d)one-to-many

8.ConsiderthefollowingUMLclassdiagram.

Whichofthefollowingis(are)trueaboutthesystemdescribedbythediagram?

c

I.AninstanceofPicturecancontainacollectionofinstancesoftheclassShape.

Ⅱ.AninstanceofShapecancontainacollectionofinstancesoftheclassPicture.

(a)IIonly(b)None(c)Ionly(d)IandII

9.Whenusingnoun-phraseanalysistomodelasoftwaresystem,whichofthefollowingshouldtypicallybeeliminatedfromthelistofpotentialclasses?

I.Referencestothesoftwaresystemitself

II.Nounsthatimplyrolesbetweenobjects

Ⅲ.Synonymstoothernounsinthelist

(a)IIandIIIonly(b)IandIIIonly

(c)IIIonly(d)I,II,andIII

10.Thestaticmodelofasoftwaresystemtypicallyincludeswhichofthefollowing?

a

I.Attributesofclasses

II.Actionsthatoccurbetweenclasses

Ⅲ.Structuralrelationshipsbetweenclasses

(a)IandIIIonly(b)IIandIIIonly

(c)I,II,andIII(d)IandIIonly

1.Thetermclassvariableisasynonymford

(a)aprivatedatafield

(b)astaticdatafield

(c)aread-onlyvariable

(d)aninstancevariable

2.ConsiderthefollowingJavaprogramsegment.c

importjava.io.*;

publicclassTest{

publicTest(){

System.out.println("default");

}

publicTest(inti){

System.out.println("non-default");

}

publicstaticvoidmain(String[]args){

Testt=newTest

(2);

}

}

Whichofthefollowingwillbeoutputduringexecutionoftheprogramsegment?

(a)Thelineoftext"default"

(b)Thelineoftext"default"followedbythelineoftext"non-default"

(c)Thelineoftext"non-default"

(d)Thelineoftext"non-default"followedbythelineoftext"default"

3.WhichofthefollowingcategorizationscanbeappliedtoboththedatafieldsandthemethodsinaJavaclass?

c

(a)nativeandnon-native

(b)defaultandnon-default

(c)staticandnon-static

(d)abstractandnon-abstract

4.WhichofthefollowingstatementsaboutclassvariablesinJavaisnottrue?

c

(a)Classvariablesrequirethemodifierstaticinthedeclarations.

(b)Allobjectshavetheirowncopyoftheclassvariabledefinedintheinstantiatedclass.

(c)Non-staticmethodsinaclasscanaccesstheclassvariabledefinedinthesameclass.

(d)Classvariablesdonotneedthereferencetotheobjectoftheinstantiatedclasstoaccessthem.

5.Ifaclasscontainsaconstructor,thatconstructorwillbeinvokedb

(a)eachtimeanobjectofthatclassgoesoutofscope

(b)eachtimeanobjectofthatclassisinstantiated

(c)oncethefirsttimeanobjectofthatclassisinstantiated

(d)onceatthebeginningofanyprogramthatusesthatclass

6.WhichofthefollowingstatementsaboutconstructorsinJavaistrue?

a

(a)Aclasscandefinemorethanoneconstructor.

(b)Aconstructormustbedefinedaspublic.

(c)Aconstructormustbedefinedasstatic.

(d)Aclassmustdefineatleastoneconstructor.

7.Ifthemethodintsum(inta,intb)isdefinedinaJavaclassC,whichofthefollowingmethodscannotcoexistasadifferentmethodinclassC?

c

(a)intsum(intx,floaty)

(b)intsum(floata,intb)

(c)intsum(intx,inty)

(d)floatsum(intx,floaty)

8.ConsiderthefollowingJavaclassdefinitions.

publicclassObject1{

protectedStringd(){

return"Hi";

}

}

publicclassObject2extendsObject1{

protectedStringd(){

returnsuper.d();

}

}

Whichofthefollowingstatementsis(are)trueregardingthedefinitions?

a

I.ClassObject2inheritsfromclassObject1.

II.ClassObject2overridesmethodd.

Ⅲ.Methoddreturnsequivalentresultswhenexecutedfromeitherclass.

(a)I,II,andIII(b)IandIIIonly

(c)IIIonly(d)IandIIonly

9.Whenasubclassdefinesaninstancemethodwiththesamereturntypeandsignatureasamethodinitsparent,theparent'smethodissaidtobed

(a)private(b)hidden(c)overloaded(d)overridden

10.WhichisaJavaaccessmodifierusedtodesignatethataparticulardatafieldwillnotbeinheritedbyasubclass?

(a)final(b)protected(c)private(d)default

1.ConsiderthefollowingJavaprogramsegment.

String[]str={"Three","Two","One"};

for(inti=0;i

System.out.println(str[i]+"/");

}

Whatwillbeoutputuponexecutionoftheprogramsegment?

a

(a)Three/Two/One/(b)Three,Two,One

(c)One,Two,Three(d)One/Two/Three/

2.ConsiderthefollowingJavaprogramsegment.a

int[]arr;

arr=newint[3];

arr[2]=19;

arr[1]=17;

arr[0]=15;

WhichofthefollowingJavastatementsissyntacticallycorrectandsemanticallyidenticaltotheprogramsegment?

(a)int[]arr={15,17,19};

(b)int[3]arr={15,17,19};

(c)intarr={15,17,19};

(d)intarr[3]={15,17,19};

3.Regardingthefollowingdeclaration,whatistheindexoftheelementcontaining45?

bint[]numbers={-1,45,6,132};

(a)0(b)1(c)45(d)2

4.LegalJavastatementstoinitializeanarrayreferenceincludewhichofthefollowing?

d

I.int[]aobj={0,1,2};

II.int[4]aobj={0,1,2};

Ⅲ.int[]aobj=newint[3];

(a)IandIIonly(b)Ionly

(c)IIIonly(d)IandIIIonly

5.IfthelengthofaparticulararrayisthevalueofLIMIT,whatistheindexofthelastiteminthatarray?

b

(a)LIMIT(b)LIMIT–1(c)LIMIT/2(d)0

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

当前位置:首页 > 人文社科 > 法律资料

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

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