This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Apart from the shortcut assignment operators (example +=, -=, *=) and unary operators (+, -, ++, --), the following rules are applied to a binary expression:
1) If either operand is of type double, the other is converted to double.
2) Otherwise, if either operand is of type float, the other is converted to float.
3) Otherwise, if either operand is of type long, the other is converted to long.
4) Otherwise, both operands are converted to type int.
As visible from the above list, the operands of type char, byte and short are atleast promoted to an int, when an expression is evaluated.
In the following example, the type of the resultant expression is double, because one of the operands is of type double.