Question: Task # 6 : Inheritance Part 1 : Write a program that demonstrates inheritance among classes. The MallardDuck and RubberDuck derived classes extend the Duck

Task #6: Inheritance
Part 1:
Write a program that demonstrates inheritance among classes.
The MallardDuck and RubberDuck derived classes extend the Duck base class. In the MallardDuck and RubberDuck derived classes, define an overridden method named getBehavior that returns the string "squeaks" and "flies", respectively.
Write code in the derived class of RubberDuck.java that has the following method:
getBehavior: an overridden method that returns the string "squeaks"
Write code in the derived class of MallardDuck.java that has the following method:
getBehavior: an overridden method that returns the string "flies"
If the input is:
Mallard Austin
Rubber Squeaker
the output when "Mallard" is the duck type, "Austin" is the duck name, "Rubber" is the duck type, and "Squeaker" is the duck name is:
Duck Information:
Austin the Mallard duck flies!
Squeaker the Rubber duck squeaks!
Write your code in this Code Check assignment below:

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!