/*****************************************************************
** DemoPromoteAndCast - demonstrate promotion and casting
**
** This program compiles without errors!
**
** (c) Scott MacKenzie, 2000                             
******************************************************************/
public class DemoPromoteAndCast
{
   public static void main(String[] args)
   {
      // integer promotion
      byte  a = 1;
      short b = a;           // byte promotes to short
      int   c = b;           // short promotes to int
      long  d = c;           // int promotes to long

      // integer casting
      c = (int)d;            // long casted to int
      b = (short)c;          // int casted to short
      a = (byte)b;           // short casted to byte

      // floating-point promotion
      float  x = 1.0f;       // 'f' needed to specify float
      double y = x;          // float promotes to double

      // character example
      char aa = 'Q';         
      int  xx = aa;          // character promotes to int
      char bb = (char)xx;    // int casted to char

      // floating-point casting
      x = (float)y;          // double casted to float
      c = (int)y;            // double casted to int
   }
}  

