Forum : object oriented programming
Brief description  about Online courses   join in Online courses
View Priyadarshni prakash 's Profile

object oriented programming

public class mytwo
{

public static String name ="Priya";
public static int age;

static void mname()
{

System.out.println("NAME");
System.out.println("my name is:" name);

}

class mythree
{


public void myage(int value)
{
age=value;
System.out.println("my current age is:" age);

}

}
public static void main(String a[])
{


mytwo a1=new mytwo();
mytwo a2=new mytwo();
a1.mname();

a2.myage(19);


}
}
Asked by Priyadarshni prakash | Jun 21, 2010 |  Reply now
Replies (1)
View arun kumar das 's Profile
Hi Priya...

Please try the below program, it works. I have made few changes to the program posted by you and please try and analyze the differences.
_______________________________________________
class mytwo
{
static String name ="Priya";
static void mname()
{
System.out.println("NAME");
System.out.println("my name is:" +name);
}
}

class mythree
{
int age;
public void myage(int value)
{
int age=value;
System.out.println("my current age is:" +age);
}
}

class MainClass
{
public static void main(String a[])
{
mytwo a1=new mytwo();
mythree a2=new mythree();
a1.mname();
a2.myage(19);
}
}
_________________________________________________

Cheers...
JT
Jun 22, 2010