Write a Java program to create a class called Animal with a method called makeSound(). Create a subclass called Cat that overrides the makeSound() method to bark.

Source Code:

class Animal {
void makeSound() {
System.out.println(“Animal sound”);
}
}

class Cat extends Animal {
void makeSound() {
System.out.println(“Bark”);
}
}

public class TestAnimal2 {
public static void main(String[] args) {
Cat c = new Cat();
c.makeSound();
}
}

Output: