Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started