Anu Kota wrote:
What is it when I say
In
Java, arrays have an hierarchy which mirrors the elements that they contain. Meaning a Dog array IS-A Animal array, since a Dog IS-A Animal. This is why you can assign a Dog array to an Animal array reference.
IMO,
you should try to avoid this, because a dog array isn't really an animal array. For example, an animal array can hold cat objects too. If you try to assign a Cat element to the array referred to by reference b, the compiler will allow it, in this case (and yes, it will fail at runtime).
Henry