CALL BY VALUE & CALL BY REFERENCE

This section of JAVA contains source codes of many different type of Java Programs to learn the JAVA Basics. These Programs are well formatted and easy to understand.

CALL BY VALUE & CALL BY REFERENCE

Postby aman_1982_2006 on September 4th, 2008, 5:54 am

Code: Select all
   //program for call by value & call by reference
class student
{
   int age;
   double fee;
   void data()
   {
      age=20;
      fee=1375.20;
   }
   void getdata(student s)
   {
      age=s.age+2;
      fee=s.fee+2;
   }
   void disp()
   {
      System.out.println(age);
      System.out.println(fee);   
   }
}
class mn2
{
   public static void main(String ar[])
            {
      student s1=new student();
      s1.data();
      s1.disp();
      s1.getdata(s1);//call by reference
      s1.disp();

   }
}
aman_1982_2006
 
Posts: 9
Joined: August 30th, 2008, 6:18 am

Return to Java

Who is online

Users browsing this forum: No registered users and 0 guests