What is the output of the following code?
3: byte a = 40, b = 50; 4: byte sum = (byte) a + b; 5: System.out.println(sum);
D.
Line 4 generates a possible loss of precision compiler error.
It only casts one operand, the following code changes the casting to cast the result of the addition.
public class Main{ public static void main(String[] argv){ byte a = 40, b = 50; byte sum = (byte) (a + b); System.out.println(sum); } }