Monday 25 January 2016

Java Tutorial : Java Polymorphism(version2)


Click here to watch in Youtube :
https://www.youtube.com/watch?v=7RZhps1BHuY&list=UUhwKlOVR041tngjerWxVccw

Click the below Image to Enlarge
Java Tutorial : Java Polymorphism(version2)
Animal.java
public 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...");
    }
}

class Dog extends Animal
{
    public void eat()
    {
        System.out.println("Dog is Eating chicken...");
    }
}
PolymorphismTest.java
public class PolymorphismTest
{

    public static void main(String[] args)
    {
        Animal animalRef = new Lion();
        animalRef.eat();

        animalRef = new Dog();
        animalRef.eat();
    }

}
Output
Lion is Eating meat...
Dog is Eating chicken...
Click the below link to download the code:
https://sites.google.com/site/javaee4321/java/PolymorphismDemo_V2_App.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/PolymorphismDemo_V2_App

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/c2560ad00704183985b315e600962c202910d529/BasicJava/PolymorphismDemo_V2_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
  • 1 comment: