class Grandfather { ... } class Father extends Grandfather{ ... } class Son extends Father { ... } Object refA = new Grandfather(); Object refB = new Father(); Object refC = new Son(); System.out.println(""+refA instanceof Grandfather); System.out.println(""+refB instanceof Grandfather); System.out.println(""+refC instanceof Grandfather);