Question: I want Java code for this question 6. Create an interface called Characteristic that has two methods likes(), says(). Create a class called Pet that

 I want Java code for this question 6. Create an interface

I want Java code for this question

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

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!