Write a code in java to meet the following requirements
. You have an abstract representation Animal that has a method sound). Since this is abstract representation class so we can't give it a implementation.
. You have three classes horae, dog and cat. You need to provide implementation of sound method according to specific class.
. Create a class by name overload. Create the method Demo() in overload class
. Overload the method by using following instructions
Demo instance of borse, cat or dog) // in method body print sound of particular animal
Demo instance of cat and dog) // in method body print sound of particular animal
Demo Instance of cat, dog and horse) // in method body print sound of particular animal
Write main method
Create objects of horse, cat and dog class.
Call overloaded methods of overloaded class by using correct parameters.
Comments
Leave a comment