class Animal{
public void animalSound(){
System.out.println("Every animal has different sound");
}
}
class Dog extends Animal{
public void animalSound(){
System.out.println("The dog says: Bow! Bow!");
}
}
class Pig extends Animal{
public void animalSound(){
System.out.println("The Pig says: Wee! Wee!");
}
}
class Cat extends Animal{
public void animalSound(){
System.out.println("The Cat says: Meow! Meow!");
}
}
public class TestPolymorphism1 {
public static void main(String args[]){
Animal myAnimal = new Animal();
Animal myDog = new Dog();
Animal myPig = new Pig();
Animal myCat = new Cat();
myAnimal.animalSound();
myDog.animalSound();
myPig.animalSound();
myCat.animalSound();
}
}