class TestNumericPromotion {

    public static void main(String[] args) {

    /** Variables *********************************************************/
    byte b0 = 10;
    byte b1 = 5;
    byte bR;            // byte result

    short s0 = 10;
    short s1 = 5;            
    short sR;           // short result

    int i0  = 10;
    int i1  = 5;
    int iR;             // int result
    
    float f0 = 10.0F;
    float f1 = 5.0F;
    float fR;           // float result
    
    double d0 = 10.0D;
    double d1 = 5.0D;
    double dR;          // double result
    
    long   l0 = 10L;
    long   l1 = 5L;
    long   lR;          // long result    
    
    /** Unary promotion **************************************************/
    // applying the unary '+' and '-' operators in the following
    // assignment statements produces  compile-errors 
                            
    //  b1 = +b0;                   // found int, required byte
    //  bR = -15.64;                // found int, required byte
    //  sR = -b0;                   // found int, required short

    /** Binary promotion ************************************************/
    // following produce compile-errors
    // bR =  b0 + b1;              // found int, required byte
    // iR = f0 + i1;               // found float, required int
    // lR = f0 + l1;               // found float, required long
    // fR = d0 + f1;               // found double, required float
    
    // following compiles and runs OK        
    fR = l0 + f1;
    System.out.println("float = long + float \t\t -> " + fR);

    /** Ternary ********************************************************/    

    // byte b8 = true ?  b0 : s0;    // found short, required byte       
    // byte b9 = true ?  b0 : i0;    // found int, byte required

    // following compiles and runs OK
    short s8 = true ? s0 : 1000;
    System.out.println("short = true ? s0 : 1000 \t -> " + s8);                
   }
}