下载此文档

JAVA基础面试题-3(答案版).doc


文档分类:IT计算机 | 页数:约15页 举报非法文档有奖
1/15
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/15 下载此文档
文档列表 文档介绍
JAVA语言基础笔试题-3
Question 1
Given:
1。 public class Team extends 。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方法,(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 e

JAVA基础面试题-3(答案版) 来自淘豆网m.daumloan.com转载请标明出处.

非法内容举报中心
文档信息
  • 页数15
  • 收藏数0 收藏
  • 顶次数0
  • 上传人phljianjian
  • 文件大小58 KB
  • 时间2021-04-14