- 1、本文档共14页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 5、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 6、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 7、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 8、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
JAVA基础面试题-3(答案版)
JAVA语言基础笔试题-3
Question 1
Given:
1. public class Team extends java.util.LinkedList {
2. public void addPlayer(Player p) {
3. add(p);
4. }
5. public void compete(Team opponent) { /* more code here */ }
6. }
7. class Player { /* more code here */ }
Which two are true? (Choose two.)
A. This code will compile.
B. This code demonstrates proper design of an is-a relationship.
C. This code demonstrates proper design of a has-a relationship.
D. A Java programmer using the Team class could remove Player
objects from a Team object.
答案: AD
考点: List接口实现,对象间泛化和关联关系
说明:
is a 关系一般用继承来表示,但此题这个继承从逻辑上不是太恰当.
Has a 关系一般来说表示某对象体内有其它对象的存在,该对象体现为属性形态,在UML中叫做关联关系。本题Team中虽然可以保存Player,但并非显式以属性形式存在。
由于LinkedList自带remove方法,可以通过Team.remove(p) 来删除player对象Question 2
Which four are true? (Choose four.)
A. Has-a relationships should never be encapsulated.
B. Has-a relationships should be implemented using inheritance.
C. Has-a relationships can be implemented using instance variables.
D. Is-a relationships can be implemented using the extends keyword.
E. Is-a relationships can be implemented using the implements
keyword.
F. The relationship between Movie and Actress is an example of an is-a
relationship.
G. An array or a collection can be used to implement a one-to-many
has-a relationship.
答案:CDEG
考点: 集合类型,对象间泛化和关联关系的理解
Has a 关系一般表示为一个类拥有一个属性,属性被封装是常见的事情。
Is a 关系一般用继承来表示,子类体内拥有父类部分。
接口的实现,也适用于 is a 关系来理解,因为接口从本质来说,也属于类的形态。
Question 3
Which two are true about has-a and is-a relationships? (Choose two.)
A. Inheritance(继承) represents an is-a relationship.
B. Inheritance represents a has-a relationship.
C. Interfaces must be used when creating a has-a relationship.
D. Instance variables can be used when creating a has-a relationship.
答案:AD
考点:对象间泛化和关联关系的理解
Question 4
Given:
10. interface Jumper { public void jump(); }
......
20. class Animal {}
......
30. class Dog extends Animal {
31. Tail tail;
32. }
......
40. class Beagle extend
您可能关注的文档
最近下载
- 生产与运作管理第五版陈荣秋习题答案.pdf
- 2023-2024学年广东省广州市天河区高一(下)期末物理试卷.pdf VIP
- 重大隐患事故判定标准考试专项测试题及答案.doc
- 人教版小学六年级数学下册期末试卷.pdf VIP
- 光耦测量方法.doc VIP
- BSISO7005-1-2011管法兰.第1部分:工业和通用管道系统用钢制法兰.pdf VIP
- 广东省深圳市语文中考试题与参考答案(2024年).docx VIP
- 部编版初中七年级历史下册知识点总结.docx VIP
- 建筑地基工程施工质量验收标准.GB50202-2018.docx VIP
- 专题06 轴对称常考压轴题型(含答案析)(八年级《新题速递·数学》(人教版)).docx
文档评论(0)