Since the right-hand side of line 7 involves only constants, the value of the expression can be determined at compile time and the Java compiler can see that a loss-less narrowing conversion to byte is possible.
On line 8, the expression involves variables, so the rules for binary numeric promotion apply.
If you declare the variables on line 3 and 4 as final, the code will compile because the value of the expression can be evaluated at compile time and the compiler can see that it can be narrowed to fit into a byte.
This won't compile though because the value 128 won't fit into a byte
Practice only makes habit, only perfect practice makes perfect.
Practice mindfully by doing the right things and doing things right.— Junilu