Why is type compatibility not applicable to primitives as well when overriding methods?

Viewed 2031

When we say that a Base class Base and its derived class Derived are type compatible we refer to the fact that a Base reference can refer to a Derived instance.
I.e. Base b = new Derived();
For the oposite a casting would be needed as the types are not type compatible.
Now is this concept not applicable to primitive types?
I mean this

short shortNumber = 10;  
int intNumber = shortNumber;  

seems like the same thing to me (as also no casting is needed and both short and int are integral types).
So when overiding a method in the base class, why is it acceptable that the return type be either the same or at least type compatible with the base's class return type but this is not applicable to integral types for example as well?
E.g. why is this not acceptable?

public class Person {    

    public int getId(){  
        return 1;  
    }           
}   


public class Employee extends Person {    

    public short getId(){  
        return 0;  
    }  

}  
4 Answers
Related