Wednesday, 27 June 2012

java program that used finalized method.

class test
{
   int n;
   test()
    {
      n=0;
    }
    test( int pn)
      {
         n = pn;
      }
    void display()
    {

          System.out.println("\n n = "+n);
    }
     protected void finalize()
    {
        System.out.println("\n releasing memory...!");
    }
}


class  finallize
{
   public static void main(String args[])
      {
           test objn = new test();   
            objn.display();
           test objnp = new test(10);   
            objnp.display();


      }
}

No comments:

Post a Comment