Originally posted by Sirishaaaaa Ghatty:
...Here dog ISA animal but vice versa is false...
A reference of type Animal could refer to a Dog if the object was originally created as a Dog and its reference was upcast to type Animal. The instanceof
test can be used to check this before attempting to downcast (which would cause a runtime exception if wrong).