Tuesday, 20 March 2018

Method Overriding in java with practical Example





package polymorph;



class bank

{



 public double getinterest(int principle,int time)

 {



     return 0;

 }

   

   

}



class HabibMetro extends bank

{

public double getinterest(int principle,int time)

 {

     return principle* time* 0.1;

 }





}



class Alfalah extends bank

{

public double getinterest(int principle,int time)

 {

     return principle* time* 0.15;

 }





}



public class Polymorph

{



    public static void main(String[] args)

    {

     

        int p=10000,year=2;

        double interest;

      HabibMetro hb=new HabibMetro();

      interest=  hb.getinterest(p, year);

     System.out.println("Simple Interest from bank habib metro is "+interest);

 

   

     Alfalah al=new Alfalah();

   interest=  al.getinterest(p, year);

       System.out.println("Simple Interest from bank Alfalah  is "+interest);

 

     

   

   

       

    }

   

}


1 comment:

Pass Dynamically Added Html Table Records List To Controller In Asp.net MVC

Controller Code: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using ...