Friday, 18 January 2013

3. Addition of two number using method


class Sample
{
            int a,b;
            void setAll(int i,int j)
            {
                        a=i;
                        b=j;
            }
            void showAll( )
            {
                        System.out.println("a= " + a + " b="+b);
            }
}
class SampleDemo
{
            public static void main(String args[ ])
            {
                        Sample ob=new Sample( );
                        ob.setAll(5,6);
                        ob.showAll( );
            }
}

No comments:

Post a Comment