For the following above code snippets, identify whether the code: 1. Fails to compile, 2. Compiles with a warning, 3. Generates an error at runtime, or 4. None of the above (compiles and runs without...


please solve with java, thanks (important)


For the following above code snippets, identify whether the code:<br>1. Fails to compile,<br>2. Compiles with a warning,<br>3. Generates an error at runtime, or<br>4. None of the above (compiles and runs without problem.)<br>Question la. AnimalHouse<Animal> house = new AnimalHouse<Cat>();<br>Question 1b. AnimalHouse<Cat> house = new AnimalHouse<Animal>():<br>Question 1c. AnimalHouse<?> house = new AnimalHouse<Cat>();<br>house.setAnimal(new Cat());<br>Question 1d. AnimalHouse house = new AnimalHouse():<br>house.setAnimal(new Dog());<br>

Extracted text: For the following above code snippets, identify whether the code: 1. Fails to compile, 2. Compiles with a warning, 3. Generates an error at runtime, or 4. None of the above (compiles and runs without problem.) Question la. AnimalHouse house = new AnimalHouse(); Question 1b. AnimalHouse house = new AnimalHouse(): Question 1c. AnimalHouse house = new AnimalHouse(); house.setAnimal(new Cat()); Question 1d. AnimalHouse house = new AnimalHouse(): house.setAnimal(new Dog());
Question 2:<br>Consider the following classes:<br>public class AnimalHouse<E> {<br>private E animal;<br>public void setAnimal(E x) {<br>animal = x;<br>}<br>public E getAnimal(O {<br>retum animal;<br>}<br>}<br>public class Animal{<br>public class Cat extends Animal {<br>public class Dog extends Animal {<br>}<br>

Extracted text: Question 2: Consider the following classes: public class AnimalHouse { private E animal; public void setAnimal(E x) { animal = x; } public E getAnimal(O { retum animal; } } public class Animal{ public class Cat extends Animal { public class Dog extends Animal { }

Jun 11, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here