Use instanceof to test whether an object is an instance of a specific class or interface.
Source Code
class Animal {}
class Dog extends Animal {
public static void main(String[] args) {
Animal myDog = new Dog();
System.out.println(myDog instanceof Animal); // true
}
}