Click here to watch in Youtube :
https://www.youtube.com/watch?v=v9FGTa_yFJA&list=UUhwKlOVR041tngjerWxVccw
Click the below Image to Enlarge
Java Tutorial : Java method overloading vs method overriding(version2) |
class Animal { public void eat() { System.out.println("Animal is eating..."); } } class Lion extends Animal { public void eat() { System.out.println("Lion is Eating meat..."); } } public class MethodOverridingExample { public static void main(String args[]) { Animal animalRef = new Lion(); animalRef.eat(); } }
Lion is Eating meat...
public class OverloadingExample { public void add(int a, int b) { int total = a + b; System.out.println("total : " + total); } public void add(int a, int b, int c) { int total = a + b + c; System.out.println("total : " + total); } public static void main(String args[]) { OverloadingExample overloadingExample= new OverloadingExample(); //Call two parameter add method overloadingExample.add(2,2); //Call three parameter add method overloadingExample.add(5, 5, 5); } }
total : 4 total : 15
https://sites.google.com/site/javaee4321/java/MethodOverridingDemo_version2-App.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/MethodOverridingDemo_version2-App
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/fa67e02bcd9efeae1c2ea3019677c5252e4db5f7/BasicJava/MethodOverridingDemo_version2-App/?at=master
See also:
No comments:
Post a Comment