August
1999 QUESTION 5 Total Marks: 20 Marks |
Click here to access other
questions
Click to access |
(a) | Explain what is meant by the term single
inheritance.
|
[1] |
(b) | What mechanism does Java provide to allow
multiple inheritance.
|
[1] |
(c) | Identify: (i) The components of a parent class which are inherited in the sub class. (ii) The components of a parent class which are not inherited in the base class.
|
[2] [1] |
(d) | (i) Variables can be polymorphic.
Explain what is meant by the term polymorphism. (ii) Explain how polymorphism contrasts to overloading.
|
[1] [2] |
(e) | (i) Define a class Animal, which has the private attributes
birthday of type Date, and number_legs, of type int. Include in this class a
constructor which takes values that is used to initialize the members. (ii) Derive a subclass of your Animal class, called Dog, which has a public name of type String. Include a constructor, which should have parameters for the members in this class and base class, and initialize the members of this class and those of the base class accordingly. (iii) Consider the following Chihuahua, which is a special type of Dog, but also has characteristics associated with the class Rat: public class Chihuahua extends Dog implements Rat { public Boolean Is_Diseased () { } Give a definition of the interface class Rat, which has the interface function Is_Diseased() and the member diseased, neither of which should be allowed to be overloaded by any class which derives from Rat.
|
[4]
[4]
[4] |