Given:
class Animal { }
class Dog extends Animal { }
class Petdog extends Dog { }
and
Which two statements inserted independently on line 3 will make this code compile? (Choose two.)
Given:
class Animal { }
class Dog extends Animal { }
class Petdog extends Dog { }
and
Which two statements inserted independently on line 3 will make this code compile? (Choose two.)
To make this code compile correctly, the return statement must adhere to the generic restrictions specified. The method returns a House with a type parameter that is a superclass of Dog. Therefore, valid return types are ones where the type parameter is either Dog itself or any supertype of Dog, which includes Animal. Hence, 'return new House<Dog>();' and 'return new House<>();' would be appropriate.
House<Dog>, House<Animal> , House<Object> , House(implicit object) because they are super class of Dog
House<Object> is not allowed class Animal{} class Dog extends Animal{} class Predog extends Dog{} class House<A extends Animal> { public House<? super Dog> build(A a) { return .. } } generic method return parameter : House <? super Dog> has super type realtionship with House<Dog>, House<Animal>, House<Object>, House<> type class parameter : <A extends Animal> following types are within bounds of type-varaible A. And it allows : House<Dog>, House<Animal>, House<Predog>, House<> so intersection is House<Dog>, House<Animal>, House<>
House<Object> is not allowed. Checked
only can return : House<Dog>, House<Animal> , House<Object> , House(implicit object) because they are super class of Dog
The answered is same for all options