Week 5 Hierarchy, Inheritance, Superclasses and Subclasses

 0    9 词汇卡    up804653
下载mp3 打印 检查自己
 
问题 English 答案 English
Inheritance goes from generalised to specialised. t/f?
开始学习
True
Describe inheritance using the is-a relationship concept
开始学习
means that one class is a subclass of another. For example, a dog is a mammal, in other words a Dog class is a subclass of Mammals class.
descri aggregation using the has-a relationship concept
开始学习
a dog has a leg (usually more than one). If in class Dog we declare a member variable of type Leg (another class) we don’t have inheritance, we have a has-a relationship (aggregation).
can we combine is-a and has-a relationships?
开始学习
yes eg:, a dog is-a mammal and it has-a leg/s
What does a subclass constructor look like
开始学习
public class Dog extends Mammals {private Leg [] legs; /* Leg is a class and legs is an array of objects of this type */ ...}
Does a subclass inherit all members of its parent class and predecesorclasses?
开始学习
No, private variables and methods are not inherited.
what is the word super used for?
开始学习
to refer hidden variables and overridden methods of the superclass
When can a subclass directly access super class members
开始学习
if they are declared publoc protected or default and are in the same package
does a subclass inherit data fields automatically?
开始学习
does a subclass inherit data fields auto 用英语
yes

您必须登录才能发表评论。