instanceof Java Keyword
Introduction The instanceof keyword is very useful to know whether an object belongs to which class. The instanceof evaluates to true if an object belongs to a specified class or its super class; else raises compilation error. The following program illustrates. public class InstanceDemo { public static void main(String args[]) { String s1 = “hello”; …