Answered step by step
Verified Expert Solution
Link Copied!

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 #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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

XML Data Management Native XML And XML Enabled Database Systems

Authors: Akmal Chaudhri, Awais Rashid, Roberto Zicari, John Fuller

1st Edition

0201844524, 978-0201844528

More Books

Students also viewed these Databases questions

Question

What is meant by economic performance?

Answered: 1 week ago

Question

122. If X is distributed as N(0, 1), find the pdf of .

Answered: 1 week ago

Question

6. Explain the strengths of a dialectical approach.

Answered: 1 week ago