elibraryportal Logo

Instanceof Operator in Java

→ In instanceof operator use to check whether an object is an instance of specified type (class, sub-class or interface).

→ The instanceof operator is also known as type comparison operator because it compares the instance with type. It returns either true or false.

Simple example of instanceof operator


c1 is an instance of Audi
c1 is an instance of Car
c1 is an instance of Vehicle

Downcasting by the help of Instanceof Operator