You can say if( animal instanceof Carnivore ) to find out if it is a predatory animal or its descendant, and you can use if( animal.getClass() == Carnivore.class ) to find out if it is definitely a predatory animal, not his descendant.
However, the fact that you need to perform this kind of check usually means that you have a flaw in your design, a missing redefined method, or something like that.
Mike nakis
source share