Using this we will create the same name method from base class to derived class only functionality will be different.



Overriding will be used to modify the internal functionality without changes on Actual Class.

No need to keyword in JAVA only method name and respective parameters should be the same.


class  Billing
{
    int amt;
    float total;
    void accept(int amt)
     {
        this.amt=amt;
     }
     void bill(int p)
     {
       total = this.amt+p;
     }
     void display()
     {
        System.out.println(total);
    }

}
class Billinggst extends Billing
{
    void bill(int p)
    {
        total = amt-(amt*.18F)+p;
    }

   public static void main(String args[])
   {
         Billinggst obj = new Billinggst();
         obj.accept(1200);
         obj.bill(700);
         obj.display(); 
   }  

}







Post a Comment

If you have any doubt in programming or join online classes then you can contact us by comment .

Previous Post Next Post