AIM:- Write a program in JAVA which is initialized through object and current object.
Program:-
class Test
{
int x,y;
void getData(int x,int y)
{
this.x=x;
this.y=y;
}
int sum()
{
return (x+y);
}
}
class Test2
{
public static void main (String args [])
{
Test t=new Test();
t.getData(10,30);
int c=t.sum();
System.out.println("Sum of two numbers is"+" "+c);
}
}
Output:- Sum of two numbers is 40
Program:-
class Test
{
int x,y;
void getData(int x,int y)
{
this.x=x;
this.y=y;
}
int sum()
{
return (x+y);
}
}
class Test2
{
public static void main (String args [])
{
Test t=new Test();
t.getData(10,30);
int c=t.sum();
System.out.println("Sum of two numbers is"+" "+c);
}
}
Output:- Sum of two numbers is 40
1 comments:
.. please! mail me question papers of Btech 8th sem cse of HPU shimla .Name of subjects:
web development (java),DSP,,,,,,SW maintenence .
e.id rkkoul2@gmail.com
Post a Comment