(Solved) : Write Program Define Hierarchy Classes Insect Butterfly Bee Mosquito Define Attributes Com Q42775100 . . .

      Write a program that will define a hierarchy of classes forInsect, Butterfly,Bee, and Mosquito, and define theattributes that are common to all in the superclass, whiledefining customized attributes in eachsubclass. Common attributes may includenumberOfWings, numberOfLegs,numberOfEyes. Come up with at least 1additional attribute for each subclass. Define apolymorphic method, fly(), at each level of thehierarchy, which will print the an imaginary sound that theinsect will make when it flies. Define aconstructor for each class that will receive thenumber of wings, the number of legs, and the number of eyes.

Next, write a driver class that willcreate an arrayList of Insectobjects. In the arrayList, add aninstance of each of the subclasses, Butterfly, Bee, and Mosquito.Once the arrayList is populated, iterate throughthe arrayList, and call the polymorphic methodfly() for each member of the arrayList. Then, endthe program.

Expert Answer

Answer to Write a program that will define a hierarchy of classes for Insect, Butterfly, Bee, and Mosquito, and define the attrib…

Leave a Comment


We are the best freelance writing portal. Looking for online writing, editing or proofreading jobs? We have plenty of writing assignments to handle.

Quick Links

Browse Solutions

Place Order

About Us

× How can I help you?