Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Task # 6 : Inheritance Part 1 : Write a program that demonstrates inheritance among classes. The MallardDuck and RubberDuck derived classes extend the Duck
Task #: Inheritance
Part :
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
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