面向对象程序设计智慧树知到课后章节答案2023年下齐鲁工业大学_第1页
面向对象程序设计智慧树知到课后章节答案2023年下齐鲁工业大学_第2页
面向对象程序设计智慧树知到课后章节答案2023年下齐鲁工业大学_第3页
面向对象程序设计智慧树知到课后章节答案2023年下齐鲁工业大学_第4页
面向对象程序设计智慧树知到课后章节答案2023年下齐鲁工业大学_第5页
已阅读5页,还剩20页未读 继续免费阅读

下载本文档

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

文档简介

面向对象程序设计智慧树知到课后章节答案2023年下齐鲁工业大学齐鲁工业大学

第一章测试

WhicheditionofJavaisgearedtowarddevelopinglarge-scale,distributednetworkingapplicationsandweb-basedapplications?()

A:StandardEdition.

B:MicroEdition.

C:IndustrialEdition.

D:EnterpriseEdition.

答案:EnterpriseEdition.

Javawasoriginallydevelopedfor:()

A:Intelligentconsumerdevices.

B:Distributedcomputing.

C:Personalcomputers.

D:Operatingsystemsdevelopment.

答案:Intelligentconsumerdevices.

WhichofthefollowingstatementsaboutJavaClassLibrariesisfalse:()

A:Javaclasslibrariesconsistofclassesthatconsistofmethodsthatperformtasks.

B:JavaclasslibrariesarealsoknownasJavaAPIs(ApplicationProgrammingInterfaces).

C:Javaclasslibrariesarenotportable

D:AnadvantageofusingJavaclasslibrariesissavingtheeffortofdesigning,developingandtestingnewclasses.

答案:Javaclasslibrariesarenotportable

The.classextensiononafilemeansthatthefile:()

A:isproducedbytheJavacompiler(javac).

B:Noneoftheabove.

C:Containsjavasourcecode

D:ContainsHTML

答案:isproducedbytheJavacompiler(javac).

Thecommand________executesaJavaapplication.()

A:java

B:Noneoftheabove

C:javac

D:run

答案:java

第二章测试

End-of-linecommentsthatshouldbeignoredbythecompileraredenotedusing()

A:Threeforwardslashes(///).

B:Twoforwardslashes(//).

C:Aslashandtwostars(/**).

D:Aslashandastar(/*).

答案:Twoforwardslashes(//).

WhichofthefollowingisnotavalidJavaidentifier?()

A:m_x

B:width

C:$_AAA1

D:myValue

答案:myValue

WhichofthefollowingcannotcauseasyntaxerrortobereportedbytheJavacompiler?()

A:Missing*/inacommentthatbeginswith/*

B:Mismatched{}

C:Anextrablankline.

D:Missing;

答案:Anextrablankline.

WhichcommandcompilestheJavasourcecodefileWelcome.java?()

A:cdWelcome.java

B:javaWelcome.java

C:javacWelcome.java

D:compileWelcome.java

答案:javacWelcome.java

WhichcommandexecutestheJavaclassfileWelcome.class?()

A:runWelcome.class

B:javaWelcome

C:javaWelcome.class

D:javawelcome

答案:javaWelcome

Whichistheoutputofthefollowingstatements?

()

A:HelloWorld

B:HelloWorld

C:WorldHello

D:HelloWorld

答案:HelloWorld

Whichstatementprintsthefloating-pointvalue123.456rightjustifiedwithafieldwidthof10?()

A:System.out.printf("%10.3f",123.456);

B:System.out.printf("%f10.3",123.456);

C:System.out.printf("%10.3d",123.456);

D:System.out.printf("%d10.3",123.456);

答案:System.out.printf("%10.3f",123.456);

Whatisthesizeinbitsofanint?()

A:16

B:32

C:64

D:8

答案:32

Whichofthefollowingistheescapecharacter?()

A:

B:*

C:"

D:

答案:\

第三章测试

Whichofthefollowingcanbeusedinaswitchstatementintheexpressionafterkeywordcase?a.aconstantintegralexpression.b.acharacterconstant.c.aStringd.anenumerationconstant.()

A:aandb.

B:aandc

C:bandc

D:All.

答案:All.

Optionalparenthesesinexpressionsaresaidtobe()

A:implied.

B:redundant.

C:binaryoperators.

D:declared.

答案:redundant.

Whichofthefollowingstatementsdoesnotalterthevaluestoredinamemorylocation?()

A:width=Integer.parseInt(input);

B:number=12;

C:inta;

D:y=y+2;

答案:inta;

WhatisthevalueofresultafterthefollowingJavastatementsexecute(assumeallvariablesareoftypeint)?

()

A:127

B:59

C:119

D:51

答案:119

Whichofthefollowingisnotanarithmeticoperator?()

A:.

B:+

C:-

D:%

答案:.

Whichofthefollowingisnotacompilationerror?()

A:Allarecompilationerrors.

B:Placingasemicolonattheendofthefirstlineofanifstatement.

C:Omittingtheleftandrightparenthesisfortheconditionofanifstatement.

D:Neglectingtoinitializealocalvariableinamethodbeforeitisused.

答案:Placingasemicolonattheendofthefirstlineofanifstatement.

Eachofthefollowingisarelationalorequalityoperatorexcept:()

A:==

B:<=

C:=!

D:>

答案:=!

Whichofthefollowingisnotacontrolstructure:()

A:Declarationstructure.

B:Selectionstructure.

C:Sequencestructure.

D:Repetitionstructure.

答案:Declarationstructure.

Whichofthefollowingisadouble-selectioncontrolstatement?()

A:for

B:if

C:do…while

D:if…else

答案:if…else

第四章测试

Thenumberofargumentsinthemethodcallmustmatchthenumberofparametersinthemethoddeclaration’sparameterlist.()

A:对B:错

答案:对

Floating-pointvaluesthatappearinsourcecodeareknownasfloating-pointliteralsandaretypefloatbydefault.()

A:错B:对

答案:错

Eachclassyoucreatebecomesanew________thatcanbeusedtodeclarevariablesandcreateobjects.()

A:library

B:type.

C:package

D:instance

答案:type.

Whichofthefollowingstatementsisfalse?()

A:Everyclassdeclarationcontainskeywordclassfollowedimmediatelybytheclass’sname.

B:Eachclassdeclarationthatbeginswiththeaccessmodifierprivatemustbestoredinafilethathasthesamenameastheclassandendswiththe.javafilenameextension.

C:Class,methodandvariablenamesareidentifiers.

D:Anobjecthasattributesthatareimplementedasinstancevariablesandcarriedwithitthroughoutitslifetime.

答案:Eachclassdeclarationthatbeginswiththeaccessmodifierprivatemustbestoredinafilethathasthesamenameastheclassandendswiththe.javafilenameextension.

Whichofthefollowingstatementsisfalse?()

A:Instancevariablescanbedeclaredanywhereinsideaclass.

B:Aclassnormallycontainsoneormoremethodsthatmanipulatetheinstancevariablesthatbelongtoparticularobjectsoftheclass.

C:Byconventionclassnamesbeginwithanuppercaseletter,andmethodandvariablenamesbeginwithalowercaseletter.

D:Instancevariablesexistbeforemethodsarecalledonanobject,whilethemethodsareexecutingandafterthemethodscompleteexecution.

答案:Instancevariablescanbedeclaredanywhereinsideaclass.

Whichofthefollowingstatementsistrue?()

A:Eachobject(instance)oftheclasssharestheclass’sinstancevariables.

B:Mostinstance-variabledeclarationsareprecededwiththekeywordpublic,whichisanaccessmodifier.

C:Noneoftheaboveistrue.

D:Variablesormethodsdeclaredwithaccessmodifierprivateareaccessibleonlytomethodsoftheclassinwhichthey’redeclared.

答案:Variablesormethodsdeclaredwithaccessmodifierprivateareaccessibleonlytomethodsoftheclassinwhichthey’redeclared.

Whenamethodterminates,thevaluesofitslocalvariablesare________.()

A:saved

B:restored

C:copied

D:lost

答案:lost

Whichofthefollowingstatementsistrue?()

A:Everyinstancevariablehasadefaultinitialvalue—avalueprovidedbyJavawhenyoudonotspecifytheinstancevariable’sinitialvalue.

B:Localvariablesareautomaticallyinitialized.

C:Theargumenttypesinthemethodcallmustbeidenticaltothetypesofthecorrespondingparametersinthemethod’sdeclaration.

D:ThedefaultvalueforaninstancevariableoftypeStringisvoid.

答案:Everyinstancevariablehasadefaultinitialvalue—avalueprovidedbyJavawhenyoudonotspecifytheinstancevariable’sinitialvalue.

Whichofthefollowingstatementsisfalse?()

A:Theasterisk(*)injavac*.javaindicatesthatallfilesinthecurrentdirectoryendingwiththefilenameextension.javashouldbecompiled.

B:Thejavaccommandcancompilemultipleclassesatonce;simplylistthesource-codefilenamesafterthecommandwitheachfilenameseparatedbyacommafromthenext.

C:Ifthedirectorycontainingtheappincludesonlyoneapp’sfiles,youcancompileallofitsclasseswiththecommandjavac*.java.

D:Alloftheabovearetrue.

答案:Thejavaccommandcancompilemultipleclassesatonce;simplylistthesource-codefilenamesafterthecommandwitheachfilenameseparatedbyacommafromthenext.

Whichofthefollowingstatementsisfalse?()

A:PrivateattributesareprecededbythekeywordprivateintheUML.

B:TheUMLmodelsoperationsbylistingtheoperationnamefollowedbyasetofparentheses.Aplussign(+)infrontoftheoperationnameindicatesthattheoperationisapublic.

C:UMLrepresentsinstancevariablesasanattributename,followedbyacolonandthetype.

D:IntheUML,eachclassismodeledinaclassdiagramasarectanglewiththreecompartments.Thetoponecontainstheclass’snamecenteredhorizontallyinboldface.Themiddleonecontainstheclass’sattributes,whichcorrespondtoinstancevariablesinJava.Thebottomonecontainstheclass’soperations,whichcorrespondtomethodsandconstructorsinJava.

答案:PrivateattributesareprecededbythekeywordprivateintheUML.

Emptyparenthesesfollowingamethodnameinamethoddeclarationindicatethatthemethoddoesnotrequireanyparameterstoperformitstask.()

A:错B:对

答案:对

Aprimitive-typevariablecanbeusedtoinvokeamethod.()

A:对B:错

答案:错

Variablesdeclaredinthebodyofaparticularmethodareknownasinstancevariablesandcanbeusedinallmethodsoftheclass.()

A:错B:对

答案:错

第五章测试

Reference-typeinstancevariablesareinitializedbydefaulttothevaluenull.()

A:对B:错

答案:对

Anyclassthatcontainspublicstaticvoidmain(String[]args)canbeusedtoexecuteanapp.()

A:错B:对

答案:对

Whichofthefollowingstatementsisfalse?()

A:Variablesdeclaredinthebodyofaparticularmethodarelocalvariablesandcanbeusedonlyinthatmethod.

B:Everymethod’sbodyisdelimitedbyleftandrightbraces({and}).

C:Keywordnullindicatesthatamethodwillperformataskbutwillnotreturnanyinformation.

D:Amethod’sparametersarelocalvariablesofthemethod.

答案:Keywordnullindicatesthatamethodwillperformataskbutwillnotreturnanyinformation.

Whichofthefollowingstatementsisfalse?()

A:Whenamethodthatspecifiesareturntypeotherthanvoidiscalledandcompletesitstask,themethodmustreturnaresulttoitscallingmethod

B:Classesoftenprovidepublicmethodstoallowtheclass’sclientstosetorgetprivateinstancevariables;thenamesofthesemethodsmustbeginwithsetorget.

C:Emptyparenthesesfollowingamethodnameindicatethatthemethoddoesnotrequireanyparameterstoperformitstask.

D:Themethod’sreturntypespecifiesthetypeofdatareturnedtoamethod’scaller.

答案:Classesoftenprovidepublicmethodstoallowtheclass’sclientstosetorgetprivateinstancevariables;thenamesofthesemethodsmustbeginwithsetorget.

Whichofthefollowingstatementsisfalse?()

A:Tocallamethodofanobject,followtheobjectnamewithacomma,themethodnameandasetofparenthesescontainingthemethod’sarguments.

B:Aclassinstancecreationexpressionbeginswithkeywordnewandcreatesanewobject.

C:Aconstructorissimilartoamethodbutiscalledimplicitlybythenewoperatortoinitializeanobject’sinstancevariablesatthetimetheobjectiscreated.

D:Scannermethodnextreadscharactersuntilanywhite-spacecharacterisencountered,thenreturnsthecharactersasaString.

答案:Tocallamethodofanobject,followtheobjectnamewithacomma,themethodnameandasetofparenthesescontainingthemethod’sarguments.

Informationispassedtoamethodin________.()

A:themethodname

B:theargumentstothemethod

C:thatmethod’sreturn

D:themethodbody

答案:theargumentstothemethod

Awell-designedmethod________.()

A:repeatscodefoundinothermethods

B:containsthousandsoflinesofcode

C:performsmultipleunrelatedtasks

D:performsasingle,well-definedtask

答案:performsasingle,well-definedtask

Todeclareamethodasstatic,placethekeywordstaticbefore________inthemethod’sdeclaration.()

A:theargumentlist

B:themethodmodifier

C:themethodname

D:thereturntype

答案:thereturntype

WhichisacorrectstaticmethodcallofMathclassmethodsqrt?()

A:sqrt(900);

B:Math.sqrt(900);

C:Mathmath=newMath();math.sqrt(900);

D:math.sqrt(900);

答案:Math.sqrt(900);

WhichofthefollowingmethodsisnotintheMathclass?()

A:log

B:ceil

C:parseInt

D:abs

答案:parseInt

第六章测试

Mathstaticmethodrandomgeneratesarandomdoublevalueintherangefrom0.0()

A:uptobutnotincluding1.0

B:uptobutnotincluding100.0

C:uptoandincluding100.0

D:uptoandincluding1.0

答案:uptobutnotincluding1.0

Whichstatementcreatesarandomvaluefromthesequence2,5,8,11and14.SupposerandomNumbersisaSecureRandomobject.()

A:2+3*randomNumbers.nextInt(5);

B:2+5*randomNumbers.nextInt(3);

C:5+3*randomNumbers.nextInt(2);

D:3+2*randomNumbers.nextInt(5);

答案:2+3*randomNumbers.nextInt(5);

Asetofnamedconstantsthatstartwiththevalue0forthefirstconstantandincrementby1foreachsubsequentconstantcanbedeclaredasa(n)________.()

A:enum

B:Noneoftheabove.

C:enumeration

D:class

答案:enum

Arraysare________.()

A:usedtodrawasequenceoflines,orrays

B:datastructuresthatcontainupto10relateddataitems

C:fixed-lengthentities

D:variable-lengthentities

答案:fixed-lengthentities

TypesinJavaaredividedintotwocategories.Theprimitivetypesareboolean,byte,char,short,int,long,floatanddouble.Allothertypesare________types.()

A:reference

B:source

C:static

D:declared

答案:reference

Whichofthefollowingstatementsisfalse?()

A:Variablesoftypebooleanareinitializedtotrue.

B:Primitive-typeinstancevariablesareinitializedbydefault.

C:Aprimitive-typevariablecanstoreexactlyonevalueofitsdeclaredtypeatatime.

D:Variablesoftypesbyte,short,int,long,floatanddoubleareinitializedto0.

答案:Variablesoftypebooleanareinitializedtotrue.

Whichofthefollowingstatementsaboutarraysaretrue?

1:Anarrayisagroupofvariablescontainingvaluesthatallhavethesametype.

2:Elementsarelocatedbyindex.

3:Thelengthofanarraycisdeterminedbytheexpressionc.length();

4:Thezerothelementofarraycisspecifiedbyc[0].()

A:3,4

B:1,2,4

C:1,2,3,4

D:1,3,4

答案:1,2,4

Aprogrammermustdothefollowingbeforeusinganarray:()

A:createthendeclarethearray.

B:declarethenreferencethearray.

C:createthenreferencethearray.

D:declarethencreatethearray.

答案:declarethencreatethearray.

Considerthecodesegmentbelow.Whichofthefollowingstatementsisfalse?int[]g;g=newint[23];()

A:Thefirststatementdeclaresanarrayreference.

B:gisareferencetoanarrayofintegers.

C:Thesecondstatementcreatesthearray.

D:Thevalueofg[3]is-1.

答案:Thevalueofg[3]is-1.

Whichofthefollowingstatementsaboutcreatingarraysandinitializingtheirelementsisfalse?()

A:Whenanarrayiscreatedwithoperatornew,thenumberofelementsmustbeplacedinsquarebracketsfollowingthetypeofelementbeingstored.

B:Thenewkeywordshouldbeusedtocreateanarray.

C:Theelementsofanarrayofintegershaveavalueofnullbeforetheyareinitialized.

D:Aforloopiscommonlyusedtosetthevaluesoftheelementsofanarray.

答案:Theelementsofanarrayofintegershaveavalueofnullbeforetheyareinitialized.

Whichofthefollowinginitializerlistswouldcorrectlysettheelementsofarrayn?()

A:intn[5]={1;2;3;4;5};

B:arrayn[int]={1,2,3,4,5};

C:int[]n={1,2,3,4,5};

D:intn=newint(1,2,3,4,5);

答案:int[]n={1,2,3,4,5};

第七章测试

Whichofthefollowingstatementsisfalse?()

A:Theclassfollowingtheextendskeywordinaclassdeclarationisthedirectsuperclassoftheclassbeingdeclared.

B:Asuperclassobjectisasubclassobject.

C:Asubclassisoftenlargerthanitssuperclass.

D:Javausesinterfacestoprovidethebenefitsofmultipleinheritance.

答案:Asuperclassobjectisasubclassobject.

Inheritanceisalsoknownasthe()

A:uses-arelationship.

B:knows-arelationship.

C:has-arelationship.

D:is-arelationship.

答案:is-arelationship.

Whichofthefollowingisnotasuperclass/subclassrelationship?()

A:Noneoftheabove.

B:Vehicle/Car.

C:Employee/HourlyEmployee.

D:Sailboat/Tugboat.

答案:Sailboat/Tugboat.

Anadvantageofinheritanceisthat:()

A:Objectsofasubclasscanbetreatedlikeobjectsoftheirsuperclass.

B:Allmethodscanbeinherited.

C:Noneoftheabove.

D:Allinstancevariablescanbeuniformlyaccessedbysubclassesandsuperclasses.

答案:Objectsofasubclasscanbetreatedlikeobjectsoftheirsuperclass.

Whichofthefollowingkeywordsallowsasubclasstoaccessasuperclassmethodevenwhenthesubclasshasoverriddenthesuperclassmethod?()

A:this.

B:base.

C:super.

D:public.

答案:super.

Usingtheprotectedkeywordalsogivesamember:()

A:privateaccess.

B:packageaccess.

C:publicaccess.

D:blockscope.

答案:packageaccess.

Superclassmethodswiththislevelofaccesscannotbecalledfromsubclasses.()

A:package.

B:private.

C:public.

D:protected.

答案:private.

EveryclassinJava,except________,extendsanexistingclass.()

A:Integer.

B:Object.

C:String.

D:Class.

答案:Object.

Overridingamethoddiffersfromoverloadingamethodbecause:()

A:Neitheroftheabove.

B:Overloadedmethodshavethesamesignature.

C:Overriddenmethodshavethesamesignature.

D:Bothoftheabove.

答案:Overriddenmethodshavethesamesignature.

第八章测试

A(n)_____classcannotbeinstantiated.()

A:final.

B:concrete.

C:abstract.

D:polymorphic.

答案:abstract.

Non-abstractclassesarecalled________.()

A:realclasses.

B:implementableclasses.

C:concreteclasses.

D:instanceclasses.

答案:concreteclasses.

Ifthesuperclasscontainsonlyabstractmethoddeclarations,thesuperclassisusedfor________.()

A:Both.

B:Neither.

C:implementationinheritance.

D:interfaceinheritance.

答案:interfaceinheritance.

Whichofthefollowingcouldbeusedtodeclareabstractmethodmethod1inabstractclassClass1(method1returnsanintandtakesnoarguments)?()

A:publicintabstractmethod1();

B:publicintnonfinalmethod1();

C:publicintmethod1();

D:publicabstractintmethod1();

答案:publicabstractintmethod1();

Whichofthefollowingstatementsaboutabstractsuperclassesistrue?()

A:abstractsuperclassesmustdeclareallmeth

温馨提示

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

评论

0/150

提交评论