欢迎来到天天文库
浏览记录
ID:16741161
大小:61.50 KB
页数:14页
时间:2018-08-24
《java基础面试题-3(答案版)》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、JAVA语言基础笔试题-3Question1Given:1.publicclassTeamextendsjava.util.LinkedList{2.publicvoidaddPlayer(Playerp){3.add(p);4.}5.publicvoidcompete(Teamopponent){/*morecodehere*/}6.}7.classPlayer{/*morecodehere*/}Whichtwoaretrue?(Choosetwo.)A.Thiscodewillcompile
2、.B.Thiscodedemonstratesproperdesignofanis-arelationship.C.Thiscodedemonstratesproperdesignofahas-arelationship.D.AJavaprogrammerusingtheTeamclasscouldremovePlayerobjectsfromaTeamobject.答案:AD考点:List接口实现,对象间泛化和关联关系说明:isa关系一般用继承来表示,但此题这个继承从逻辑上不是太恰当.Hasa
3、关系一般来说表示某对象体内有其它对象的存在,该对象体现为属性形态,在UML中叫做关联关系。本题Team中虽然可以保存Player,但并非显式以属性形式存在。由于LinkedList自带remove方法,可以通过Team.remove(p)来删除player对象。Question2Whichfouraretrue?(Choosefour.)A.Has-arelationshipsshouldneverbeencapsulated.B.Has-arelationshipsshouldbeimplem
4、entedusinginheritance.C.Has-arelationshipscanbeimplementedusinginstancevariables.D.Is-arelationshipscanbeimplementedusingtheextendskeyword.E.Is-arelationshipscanbeimplementedusingtheimplementskeyword.F.TherelationshipbetweenMovieandActressisanexample
5、ofanis-arelationship.G.Anarrayoracollectioncanbeusedtoimplementaone-to-manyhas-arelationship.答案:CDEG考点:集合类型,对象间泛化和关联关系的理解Hasa关系一般表示为一个类拥有一个属性,属性被封装是常见的事情。Isa关系一般用继承来表示,子类体内拥有父类部分。接口的实现,也适用于isa关系来理解,因为接口从本质来说,也属于类的形态。otherstaffoftheCentre.Duringthewar
6、,ZhuwastransferredbacktoJiangxi,andDirectorofthenewOfficeinJingdezhen,JiangxiCommitteeSecretary.Startingin1939servedasrecorderoftheWestNorthOrganization,SecretaryoftheSpecialCommitteeAfterthevictoryofthelongMarch,hehasbeentheNorthwestOfficeoftheFeder
7、ationofStateenterprisesMinister,ShenmufuguSARmissions,DirectorofNingxiaCountypartyCommitteeSecretaryandrecorderoftheCountypartyCommitteeSecretary,MinistersandQuestion3Whichtwoaretrueabouthas-aandis-arelationships?(Choosetwo.)A.Inheritance(继承)represen
8、tsanis-arelationship.B.Inheritancerepresentsahas-arelationship.C.Interfacesmustbeusedwhencreatingahas-arelationship.D.Instancevariablescanbeusedwhencreatingahas-arelationship.答案:AD考点:对象间泛化和关联关系的理解Question4Given:10.interfaceJumper{publicvoidjump();}..
此文档下载收益归作者所有