Exam 1z0-808 All QuestionsBrowse all questions from this exam
Question 65

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?

    Correct Answer: D

    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.

Discussion
Mamlouk_MedOption: D

correct answer is D the cat class doesn't extended by tiger

pawankalyanOption: D

correct answer is D

MintyUikeyOption: E

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 "

mesonjesiOption: D

correct answer is D

somrita90Option: D

D is the answer because Tiger is child class of Cat, generic type is Tiger, they are trying to add Cat object

sina_Option: A

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"

tuyetanOption: D

D if no shuffling of order of options :))

KolodetsOption: D

Cat is not necessarily a Tiger and therefore doesn't extend Tiger => D

Vicky_65Option: D

D is correct.Because can;t able to add parent object in child list.

shivkumarxOption: D

Answer is D E must be a typo - it compiles otherwise

DiamondWhiteOption: D

Maybe they chose E because there is a typo.. List is spelled as LIst..

hexadecimal82

D and E

archer1903Option: D

correct answer is D

HersNo

Correct answer is D,E. why E , because ArrayList() but not ArrayLIst()

admin8Option: D

Answer is D!!!!

JongHwaOption: D

DDDD is correct

Kolodets

yes agree

brianhuang881215Option: E

E is an indecisive answer