Following code is not getting compiled and is giving below error upon compilation error at line 1
:
Type mismatch: cannot convert from fourLegged to Dog1
From my understanding it should get compiled successfully and should not give any error.
public class Test1 {
public static void main(String[] args) {
MyAnimal obj = new MyAnimal();
Dog1 carDoor = obj.get()//Line 1;
}
}
class MyAnimal<C extends BlackDog> extends AbstractAnimal<C> implements Animal1 {
}
abstract class AbstractAnimal<C extends FourLegged> {
public C get() {
return null;
}
}
interface Animal1 {
public Dog1 get();
}
interface FourLegged {
}
interface Dog1 extends FourLegged {
}
interface BlackDog extends Dog1 {
}
Can some one help me understand this behavior.