Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

6. Create an interface called Characteristic that has two methods likes(), says(). Create a class called Pet that implements the above interface, and has two

image text in transcribed

6. Create an interface called Characteristic that has two methods likes(), says(). Create a class called Pet that implements the above interface, and has two private data members name and food of string type. Do not define the interface methods in Pet. Write a 2- argument constructor to assign values to its data members. Write 2 member functions to return the name, and food values respectively. Derive a class called Dog from the Pet class that includes a data member favorite_activity. Write a 3-argument constructor to initialize values. Implement the likes() function to display the message in the following format: likes and . Implement the says() function to display the message in the following format: says Bow Bow!". Create another derived class called Cat from the Pet class that includes a data member called Age. Write a 3-argument constructor to initialize values. Implement the likes() function to display the message in the following format: likes at the age of . Implement the says() function to display the message in the following format: " says Mew Mew!". Write main function to create an ArrayList of Pet to hold two Dog objects and three Cat objects and assign appropriate values to its data members through constructor. Sort the list based on their name. Call the likes and says member functions to display the messages

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

More Books

Students also viewed these Databases questions