Saying animals

Report a typo

You have four classes: Animal, Cat, Dog, and Duck. The class animal has a method say().

Override the method in all subclasses. Overridden methods should output what these animals say (using System.out.println).

Cat:

meow-meow

Dog:

arf-arf

Duck:

quack-quack
Write a program in Java 17
class Animal {

public void say() {
System.out.println("...An incomprehensible sound...");
}
}

class Cat extends Animal {

}

class Dog extends Animal {

}

class Duck extends Animal {

}
___

Create a free account to access the full topic