class Animal {
public String toString() {
return "This is an animal ";
}
}
class Dog extends Animal {
public void sound() {
System.out.println("Woof Woof");
}
}
public class MainClass {
public static void main(String[] a) {
Dog aDog = new Dog();
if (aDog instanceof Animal) {
Animal ani = (Animal) aDog;
System.out.println(ani);
}
}
}
This is an animal