Given the following class declarations:
✑ public abstract class Animal
✑ public interface Hunter
✑ public class Cat extends Animal implements Hunter
✑ public class Tiger extends Cat
Which answer fails to compile?
Given the following class declarations:
✑ public abstract class Animal
✑ public interface Hunter
✑ public class Cat extends Animal implements Hunter
✑ public class Tiger extends Cat
Which answer fails to compile?
In option D, the code declares an ArrayList with the type parameter Tiger, but then attempts to add a Cat object to it. Since Cat is a superclass of Tiger, this violates the type safety provided by generics in Java, resulting in a compilation error. Instances of a superclass cannot be added to a collection that expects a subclass. Therefore, the code in option D fails to compile.
correct answer is D the cat class doesn't extended by tiger
correct answer is D
This is the explanation I got for option E, Found it silly though :- "Look at the right side of the declaration ArrayLIst() rather than ArrayList "
correct answer is D
D is the answer because Tiger is child class of Cat, generic type is Tiger, they are trying to add Cat object
A is correct answer at D: reference object of Tiger and make object of Cat but {Class Tiger extands Cat} Tiger Is a Cat and Cat is Animal that has a Hunter and E because of "ArratLIst"
D if no shuffling of order of options :))
Cat is not necessarily a Tiger and therefore doesn't extend Tiger => D
D is correct.Because can;t able to add parent object in child list.
Answer is D E must be a typo - it compiles otherwise
Maybe they chose E because there is a typo.. List is spelled as LIst..
D and E
correct answer is D
Correct answer is D,E. why E , because ArrayList() but not ArrayLIst()
Answer is D!!!!
DDDD is correct
yes agree
E is an indecisive answer