Write program to type casting.

Program:

//create class Nasa as file name
class Nasa
{
    //define main method of program where the execution of program begins
    public static void main(String args[])
    {
        //define variable data
        int n=65;
        double m=n;
        int k=(int)m;
       
        //define print function
        System.out.println(m);
        System.out.println(k);
       
        //float data type
        float rate=(float)3.8;
        System.out.println(rate);  

        float rt=23.7f;
        System.out.println(rt);

        //long data type
        long num=2147483648L;
        System.out.println(num);       
   
        char ch='A';
        int val=ch;
        System.out.println(val);   

        char ch1='a';
        int val1=ch1;
        System.out.println(val1);
    }
}


Sample output:

Post a Comment

Previous Post Next Post