Question: JAVA please read the yellow highlight.. YOU DO NOT NEED TO INITIALIZE THOSE POINTS. THANK YOU. Assume that the following classes have been created. Do
JAVA
please read the yellow highlight.. YOU DO NOT NEED TO INITIALIZE THOSE POINTS. THANK YOU.

Assume that the following classes have been created. Do not write any import statements. An abstract class named Pet. This class has a private String attribute called name that is set by the constructor. The Pet slass also has a public method called getName() A sub-class of the Pet class named Dog that has a constructor that takes a single String parameter for name. The constructor passes this value upto the super class for initialisation. . The Dog class also has a method called fetch that returns a String value. A sub-class of the Pet class named Cat that has a constructor that takes a single String parameter for name. The constructor passes this value upto the super class for initialisation. What you need to do: 1.) Declare and instantiate a single array that can hold both Dog and Cat objects. The size of the array should be 3. 2.) Instantiate a Dog with the name Fido 3.) Instantiate an Cat with the name "Toby" 4.) Instantiate a Dog with the name "Henry. 5.) Assign the Dog named Fido to the first position in the array. 6.) Assign the Cat named Toby to the second position in the array. 7.) Assign the Dog named Henry to the third position in the array 8.) Write a standard for loop that will iterate through the array 9.) If a dog object is encountered then it should call the fetch method and print the results of the method call to the console 10.) If a cat gbiect is encountered then it should call the getName method and print the results of the method call to the console
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
