What is the ‘instanceof’ operator used for in Java?
instanceof keyword is a binary operator used to test if an object (instance) is a subtype of a given Type. Imagine: interface Domestic {} class Animal {} class Dog extends Animal implements Domestic {} class Cat extends Animal implements Domestic {} Imagine a dog object, created with Object dog = new Dog(), then: dog instanceof … Read more