Which of the following is illegal ?
Select 1 option
Correct Option is : D
A. is wrong.
This is valid because 320 is below the maximum value that a char can take, which is 2^16 - 1. Remember that char can take only positive values.
B. is wrong.
320 is an int and so can be assigned to an int variable.
f = 320.0 is not valid as 320.0 would be a double.
C. is wrong.
This is valid because an int can be assigned to a double without any cast.
D. is wrong.
320 cannot fit into a byte so you must cast it.: byte b = (byte) 320;