Saturday, June 23, 2018

WAP IN JAVA TO SHOW CALL BY VALUE

class Twelve{
 
        int x=3;
        void increment(int a)
    {
        System.out.println("Value of a before increment: "+a);
        a=a+1;
        System.out.println("Value of a after increment: "+a);
    }
         public static void main(String args[])
    {
        Twelve op=new Twelve();
        System.out.println("Value of x before calling increment(): "+op.x);
        op.increment(4);
        System.out.println("Value of x after calling increment(): "+op.x);
    }
 
    }
 
 

No comments:

Post a Comment