Wednesday 20 January 2016

Java Tutorial : Java method overriding(Bank)


Click here to watch in Youtube :
https://www.youtube.com/watch?v=5qfkFWYV-aY&list=UUhwKlOVR041tngjerWxVccw

Click the below Image to Enlarge
Java Tutorial : Java method overriding(Bank) 
Bank.java
public class Bank
{
    public int getRateOfInterest()
    {
        return 5;
    }
}
Hdfc.java
public class Hdfc extends Bank
{

    @Override
    public int getRateOfInterest()
    {
        return 10;
    }
}
Icici.java
public class Icici extends Bank
{
    @Override
    public int getRateOfInterest()
    {
        return 8;
    }
}
MethodOverrideTest.java
public class MethodOverrideTest
{

    public static void main(String[] args)
    {
        Bank bankref = new Hdfc();
        int rateOfInterest = bankref.getRateOfInterest();
        
        System.out.println("Rate of Interest provided by HDFC : " + rateOfInterest);

        bankref = new Icici();
        rateOfInterest = bankref.getRateOfInterest();
        
        System.out.println("Rate of Interest provided by ICICI : " + rateOfInterest);
    }

}
Output
Rate of Interest provided by HDFC : 10
Rate of Interest provided by ICICI : 8
Click the below link to download the code:
https://sites.google.com/site/javaee4321/java/MethodOverridingDemo-Bank-App.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/MethodOverridingDemo-Bank-App

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/fa67e02bcd9efeae1c2ea3019677c5252e4db5f7/BasicJava/MethodOverridingDemo-Bank-App/?at=master

See also:

  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • No comments:

    Post a Comment