Question: in java 1. Create an interface Edible that has one method howToEat that returns a String 2. Create an abstract Animal class that has one

in java

1. Create an interface Edible that has one method howToEat that returns a String

2. Create an abstract Animal class that has one abstract method sound that returns a String

3. Create an abstract Fruit class.

4. The Fruit class will implement the Edible interface (no code should be in this class)

5. Create an Apple class that inherits from Fruit

6. Create an Orange class that inherits from Fruit

7. Create a Lion class that inherits from Animal

8. Create a Chicken class that inherits from Animal and implements the Edible interface Draw a UML diagram to show the relationship between the classes and interface.

Testing:

1. Create and driver to test the classes

a. Create an array of type Object that contain each class

b. Create an array of type Edible to test all Edible object

Discussion:

In Testing 1.a there is a problem. How do you know what the object type is to test the howToEat or sound method.

You will need to do this: A instanceof B returns true if A has a relationship with B through inheritance or an interface.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!