userimage

what is the difference between isinstance and isassignablefrom in java

When we say like below 

class.isAssignableFrom(obj.getClass())
And 
clazz.isInstance(obj)

So what is the differences between these. 

userimage

class.isInstance(obj) is for checking an instance and returns true when the parameter obj is non-null and can be cast to class without raising a ClassCastException. In other words we can say the obj is an instance of class or its subclasses. class.isAssignableFrom(Some.class) will return true if class is the same as, or a superclass or superinterface of, Other. Other can be a class or an interface. It answers true if Other can be converted to a class.

Answer is