Help me detect my error
I was going through polymorphism in Java tutorials of Sololearn wherein I found this code snippet. class Animal { public void makeSound() { System.out.println("Grr..."); } } class Cat extends Animal { public void makeSound() { System.out.println("Meow"); } } class Dog extends Animal { public void makeSound() { System.out.println("Woof"); } } class Program { public static void main(String args[ ]) { Animal a = new Dog(); Animal b = new Cat(); a.makeSound(); b.makeSound(); } } the above one is the code snippet provided by the Sololearn. If i add object c for class Animal, the code snippet doesn't work and is showing error. Please help me out class Animal { public void makeSound() { System.out.println("Grr..."); } } class Cat extends Animal { public void makeSound() { System.out.println("Meow"); } } class Dog extends Animal { public void makeSound() { System.out.println("Woof"); } } class Program { public static void main(String args[ ]) { Animal a = new Dog(); Animal b = new Cat(); Animal c = new Animal(); a.makeSound(); b.makeSound(); c.makeSound(); } }