The Type Comparison Operator instanceof
The instanceof operator compares an object to a specified type.
We generally use it to test if an object is an instance of a class, an instance of a subclass, or an instance of a class that implements a particular interface.
Downcasting with java instanceof operator
When Subclass type refers to the object of Parent class, it is known as downcasting.
If we perform it directly, compiler gives Compilation error.
If you perform it by typecasting, ClassCastException is thrown at runtime. But if we use instanceof operator, down casting is possible.