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) |
public class Bank { public int getRateOfInterest() { return 5; } }
public class Hdfc extends Bank { @Override public int getRateOfInterest() { return 10; } }
public class Icici extends Bank { @Override public int getRateOfInterest() { return 8; } }
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 : 8Click 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:
No comments:
Post a Comment