Anyone to explain this code for my better understanding?
//here is the code class Animal { public void animalSound() { System.out.println("The animal makes a sound"); } } class Pig extends Animal { public void animalSound() { System.out.println("The pig says: wee wee"); } } class Dog extends Animal { public void animalSound() { System.out.println("The dog says: bow wow"); } } class MyMainClass { public static void main(String[] args) { Animal myAnimal = new Animal(); Animal myPig = new Pig(); Animal myDog = new Dog(); //please explain the code three rows before this comment! Why the words in front of the object for them are all Animal? Thank you. myAnimal.animalSound(); myPig.animalSound(); myDog.animalSound(); } }