class Animal {
public void makeSound() {
System.out.println("Som generico");
}
}
class Cachorro extends Animal {
@Override
public void makeSound() {
System.out.println("gritar");
}
}
public class Main {
public static void main(String[] args) {
Cachorro cachorro = new Cachorro();
if (cachorro instanceof Animal) {
Animal animal = (Animal) cachorro;
animal.makeSound();
}
}
}