About the following code snippet statements is correct?
byte b1=1,b2=2,b3,b6;
final byte b4=4,b5=6;
b6=b4+b5;
b3=(b1+b2);
System.out.println(b3+b6);
A. Output: 13
B. Statement: b6 = b4 + b5 compile error
C. statement: b3 = b1 + b2 compile error
D. runtime exception is thrown
This title selected C.
The modified final variables are constants, where b6 = b4 + b5 b6 = 10 can be seen; at compile time has become the b6 = 10
And b1 and b2 are a byte, calculation time will increase their type int, and then calculated, after calculating b1 + b2 already int type, assigned to b3, b3 is a byte, a type mismatch, the compiler does not java by, we need to be cast.
In Java byte, when short, char calculation will be promoted to int type.