How to use the instanceof keyword?
To check whether an object is of a particular type (class or interface type) you can use instanceof operator. The instanceof operator is used only for object reference variable.
x instanceof y can be read as x is-a y.
The instanceof returns true if the reference variable being tested is of the type being compared to. It will still return true if the object being compared is assignment compatible with the type on the right.
For interface type, an object is said to be of a particular interface type (meaning it will pass the instanceof test) if any of the object's superclasses implement the interface.