What is numeric promotion?

What is numeric promotion?

Numeric promotion contexts allow the use of an identity conversion or a widening primitive conversion. Numeric promotion is the conversion of a smaller numeric type to a larger numeric type,so that integer and floating-point operations may take place. In numerical promotion,byte, char, and short values are converted to int values. The int values are also convertedto long values, if necessary. The long and float values are converted to double values. Numeric promotions are used to convert the operands of a numeric operator to a common type so that an operation can be performed. In java, if u are arithematic operator on the operands then :
    *  If either operand is of type  double, the other is converted to  double.

    * Otherwise, if either operand is of type float, the other is converted to float.

    * Otherwise, if either operand is of type long, the other is converted to long.

    * Otherwise, both operands are converted to type int.

 

By:Jalees
Date:2015-01-09 00:00:00

Post Your Answers


User Email:

User Name:
Answers:

Related Java Subjective Links

Java Subjective interview questions and answers for experienced and fresher