Page 73 - CA_Blue( J )_Class9
P. 73

5          int i=550;
                   6          long l=i;

                   7          float f= l;
                   8          System.out.println("Integer type value : "+i);

                   9          System.out.println("Long type value : "+l);
                  10          System.out.println("Float type value : "+f);
                  11      }

                  12  }

                 You will get the following output:
















                  Program 15     Write a program to demonstrate implicit conversion.

                   1  import java.util.*;
                   2  class implicite_calculation

                   3  {
                   4      public static void main()
                   5      {

                   6          int a,b,sum;

                   7          double avg;
                   8          a=45;
                   9          b=60;

                  10          sum=a+b;
                  11          avg=sum/3.0;

                  12          System.out.println("Sum  : "+sum);
                  13          System.out.println("Average : "+avg);

                  14      }
                  15  }










                                                                                               Values and Types  71
   68   69   70   71   72   73   74   75   76   77   78