I\'d a code snippet:
class AutoTypeCast{
    public static void main(String...args){
        int x=10;
        byte b=20;//no compilation error
        byte c=x;         
        
Because compiler is not able to figure out the value of X at compile time. So it assume that X can contain value which is greater than byte range. If you make variable X as final then it will not give you compile time error.
        final int x=10;
        byte b=20;//no compilation error
        byte c=x;//no compilation error