When an operator combine two or more operands in different number format all the numbers are converted to a common data type before they are combined.
1. If at least one of the operands is type of double others are also converted to double.
2. Else if either of operands is type of float other one is also converted to float.
3. Else if either of operands is type of long other one is also converted to long.
4. Else bothe operands are converted to int.
This is called auto casting.
Eg. When 'A'+2
char values 'A' is converted to the int value 65 and the final result type is int. Result should be 65+2=67.
In java number type conversion is always legal if there is no loss of information.
From byte to short, int, long, float, double.
From short to char, int, long or double.
From int to long or double.
From int to float and From long to float or double conversions are also legal, but they may lose informations.
Double can convert into int or float or byte using casting. But there may be information loss.
Eg. double a=3.7
int b=(int)a
value of b is 3. Whether it is 3.1 ----- 3.9.