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.
Answer to Write a program that will define a hierarchy of classes for Insect, Butterfly, Bee, and Mosquito, and define the attrib…