Type promotion rule

Q. Explain type conversion rules for basic data types in java.

Ans. Type promotion rule: Java automatically each bits or short operant to int when evaluating an expression. As usual as the automatic promotions are, they can cause confusing compile time errors.

Type promotions rule: Java defines several types promotions rule:

1.      Byte and short values are promotes in your int.

2.      If one operand is long then whole operation is promoted to long.

3.      If one is float, then the expression will be float.

4.      If any is double, then result will be double.




   Related Questions in Programming Languages

©TutorsGlobe All rights reserved 2022-2023.