Question: Consider the class Animal below. 1) Write two subclasses of Animal named Lion and Cow The constructor Lion(String species, String size) in the Lion subclass

 Consider the class Animal below. 1) Write two subclasses of Animal

Consider the class Animal below. 1) Write two subclasses of Animal named Lion and Cow The constructor Lion(String species, String size) in the Lion subclass initializes the instance variables of the superclass. In the Lion subclass the method getSound() is overridden so that getsound() in Lion will return the string "Roar" The constructor Cow(String species, String size) in the Cow subclass initializes the instance variables of the superclass.In the Cow subclass, the method getSound() is overridden so that getSound() in Cow will return the string "Moo" 2) Add to the class Lioncounter a method with signature public static int countLion(Animal) vlist) which returns the number of animals in vlist which are instances of Lion Answer: (penalty regime: 0,0,0,2,4,6,... 96) 9 Reset answer 1. public class Animal 2 private String species; private String size; public Animal (String species, String size) { this species-species; this.size-size; } public String getSpecies(){ return species; 10 } 11 public String getSize(){ return size; 13 } 14 15 public String getSoundO{ 16, return 17 } 18) 19 20 Madd subclasses below 21 22 class LionCounter 23. //add method here 24 ) 12

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!