What will be the error in the following Java code?

Q & ACategory: JavaWhat will be the error in the following Java code?
Admin Staff asked 5 years ago

What will be the error in the following Java code?

    byte b = 50;
    b = b * 50;

a) b cannot contain value 100, limited by its range
b) * operator has converted b * 50 into int, which can not be converted to byte without casting
c) b cannot contain value 50
d) No error in this code

1 Answers
Admin Staff answered 5 years ago

b) * operator has converted b * 50 into int, which can not be converted to byte without casting