Question: QUESTION 1 (a) Explain the relationships between the classes in the code below. Write a Test class with a main method. In the main method

QUESTION 1 (a) Explain the relationships between the classes in the code below. Write a Test class with a main method. In the main method create four objects, one for each class and print to the screen the result of testing if each object is an instance of Animal. (7 marks) public class Animal { } public class Mammal extends Animal { } public class Reptile extends Animal { } public class Dog extends Mammal { } (b) There are three types of Inheritance supported in Java. Describe each type and provide a diagram for each. (6 marks) (c) Analyze the following code below. Assume the classes Vehicle and Car are written and are public. public class Electric Car extends Vehicle, Car{} 1) Why will this cause a problem? (ii) What options do I have for Vehicle and Car to fix the problem? (7 marks) Total (20 marks)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
