Week 5 Hierarchy, Inheritance, Superclasses and Subclasses

 0    9 cartonașe    up804653
descarcă mp3 printează joacă Testează-te
 
Întrebare English Răspuns English
Inheritance goes from generalised to specialised. t/f?
începe să înveți
True
Describe inheritance using the is-a relationship concept
începe să înveți
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
începe să înveți
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?
începe să înveți
yes eg:, a dog is-a mammal and it has-a leg/s
What does a subclass constructor look like
începe să înveți
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?
începe să înveți
No, private variables and methods are not inherited.
what is the word super used for?
începe să înveți
to refer hidden variables and overridden methods of the superclass
When can a subclass directly access super class members
începe să înveți
if they are declared publoc protected or default and are in the same package
does a subclass inherit data fields automatically?
începe să înveți
does a subclass inherit data fields auto în engleză
yes

Trebuie să te autentifici pentru a posta un comentariu.