Sail E0 Webinar
Question

What is the error in this code?
byte b = 50;
b = b * 50;


Options:
A .  b can not 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 can not contain value 50.
D .  No error in this code
Answer: Option B

While evaluating an expression containing int, bytes or shorts , the whole expression is 

converted to int then evaluated and result is also of type int.



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers