早教吧 育儿知识 作业答案 考试题库 百科 知识分享

Java:hasa;isa意义1.Whichstatementistrueabouthas-aandis-arelationships?AA.Inheritancerepresentsanis-arelationship.B.Inheritancerepresentsahas-arelationship.C.Interfacesmustbeusewhencreatingahas-arelationship.D.Instan

题目详情
Java:has a ; is a意义
1. Which statement is true about has-a and is-a relationships?A
A.Inheritance represents an is-a relationship.
B.Inheritance represents a has-a relationship.
C.Interfaces must be use when creating a has-a relationship.
D.Instance variables must be used when creating an is-a relationship.
这道题中的has-a和is-a是什么意思?
▼优质解答
答案和解析
has-a 有一个, is-a 是一个.
比如继承 ,有一个图形类和一个圆形类,圆形类继承于图形类.可以说圆形是一个图形,就是is-a的意思.
比如组合,一个汽车类和一个轮子类,汽车有轮子,就是has-a的意思.