5. Generics: (16 points] Consider the following classes public class AnimalHouse
ID: 3914955 • Letter: 5
Question
5. Generics: (16 points] Consider the following classes public class AnimalHouse public class Animalf private E animal; public void setAnimal(E x) f animal - x; public class Cat extends Animal public E getAnimal) return animal; public class Dog extends Animal For the following Java statements, identify whether the code: Fails to compile or Compiles with a warning Generates an error at runtime, or None of above (compiles and runs without problem) . . (a) AnimalHouse Animal house new Animal HousecCat O: (b) AnimalHousesDog> house = new AnimalHouse house = new AnimalHouse-Cap-(); (d) AnimalHouse house new AnimalHouse0:Explanation / Answer
a) Compilation error b) Compilation error c) None of the above(Works fine) d) None of the above(Works fine)
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.