Monday, 25 January 2016

Java Tutorial : Java Polymorphism(version3)


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

Click the below Image to Enlarge
Java Tutorial : Java Polymorphism(version3) 

Java Tutorial : Java Polymorphism(version3) 
Java Tutorial : Java Polymorphism(version3) 
Java Tutorial : Java Polymorphism(version3) 
Java Tutorial : Java Polymorphism(version3) 
Java Tutorial : Java Polymorphism(version3) 
Animal.java
public class Animal
{
    public void makeNoise()
    {
        System.out.println("Some sound.");
    }
}

class Lion extends Animal
{
    public void makeNoise()
    {
        System.out.println("Roar.");
    }
}

class Dog extends Animal
{
    public void makeNoise()
    {
        System.out.println("Bark.");
    }
}
PolymorphismTest.java
public class PolymorphismTest
{

    public static void main(String[] args)
    {
        Animal animalRef = new Lion();
        animalRef.makeNoise();//Prints Roar.
        
        animalRef = new Dog();
        animalRef.makeNoise();//Prints Bark.
    }

}
Output
Roar.
Bark.

Click the below link to download the code:
https://sites.google.com/site/javaee4321/java/PolymorphismDemo_V3_App.zip?attredirects=0&d=1

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

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