Objective: Performing the Addition and substraction using objects.
Code :
class ys
{
public int add(int a,int b)
{
return(a+b);
}
static int sub(int c,int d)
{
return(c-d);
}
}
class test
{
public static void main(String args[])
{
ys x1=new ys();
ys x2=new ys();
int p=x1.add(4,5);
int q=x2.sub(15,5);
System.out.println("add"+p);
System.out.println("sbu"+q);
}
}
Output :
No comments:
Post a Comment