Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java (12 points) Given the following inheritance of the statements in the main m

ID: 3601098 • Letter: J

Question

Java (12 points) Given the following inheritance of the statements in the main method that ollows. Or write "Comple time en 2. hierarchy, write the output generated by each occur error" if one would public abstract class Animal f public void id) public class jungle Cat mittens new Cat) Calico khali-new Callcol: Dog feedo new DoBl0 System.out.printin (I am an animal.") public class Cat extends Animal t public void groom) a) mittens.idl) b) feedo.play System.out.print("Prr) 1 // end Cat public class Dog extends Animal I public void play) c) khall.id System.out printin("Ruff Bite"): ) II end Dog public class Calico extends Cat List the methods avallable to khall. public void id) System.out.print!"1 am a Calico and ": super.id) public void play0) System.out.println('meow Scratch"l ) //end Calico

Explanation / Answer

==============================
a) mittens.id();
------------
Answer:
------------

   I am an animal.
--------------------
Explanation:
--------------------

    mittens is object of type Cat. Cat extends Animal
   since Cat does not overridden the id method.
   Hence id function of Animal gets executed and I am an animal printed on the console.
  
==============================
b) feedo.play();
------------
Answer:
------------

   Ruff Bite
-------------------
Explanation:
-------------------

   feedo is an object of type Dog. Dog class has the play method.
   Hene play method gets executed and Ruff Bite printed on console.
==============================
c) feedo.groom();
-------------
Answer:
-------------

   Compile time error
-------------------
Explanation:
-------------------

   feedo is an object of type Dog. There is no groom method in Dog class.
   Hence compiler throws error.
==============================
c) khali.id();
------------
Answer:
------------

   I am a Calico and I am an animal.
--------------------
Explanation:
--------------------

   khali is an object of type Calico.Which extends Cat , Cat extends Animal
   Calico has id method in it.   Hence I am a Calico and printed first then next
   statement super.id() is invoked of Animal calss and I am an animal printed
   on console.
  
==============================

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote