Java OCA OCP Practice Question 117

Question

Will the following code compile?

1. byte b = 2; 
2. byte b1 = 3; 
3. b = b * b1; 
  • A. Yes
  • B. No


B.

Note

The code will fail to compile at line 3.

The two operands, which are originally bytes, are converted to ints before the multiplication.

The result of the multiplication is an int, which cannot be assigned to byte b.




PreviousNext

Related