Question: Create a java project and name it FinalExam_Q2: (0.25 for each error in the code) 1- Create an abstract class 'Animals' (1m) 2- Add three
Create a java project and name it FinalExam_Q2: (0.25 for each error in the code)
1- Create an abstract class 'Animals' (1m)
2- Add three attributes to the Animals class: Id, type and color. (1m)
3- Add two abstract methods to the class:sound and eat'. (2m)
4- Add non abstract method display that print the id, type and color on one line. (1m)
5- create a class 'Cats' with a method 'sound' which prints "meow" and method eat which return meet. (2m).
6- create a class 'sheep' with a method 'sound' which prints "baaaaaaa" and method eat which return grass. (2m)
7- Add price attribute the sheep class and name attribute to the Cats class. (0.5m)
8- Both class inherit form the class 'Animals'. (1m)
9- Insert constructors in all classes and overload the constructor in the Cats Class. (1m)
10- Override the display () method in both classes: Cats and Sheep to print the extra information. (1m)
11- In the main program
a. Create two objects: one for Cats and one for sheep. (1m)
b. Call their respective methods. (1m)
12- Test your program (0.5m)
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
