Ryan McClain wrote:If Product is a parent of Book, then why can't a Product object be explicitly cast to a Book object?
Because, even though a particular
Product might be a
Book, the compiler has no way of knowing whether it IS a
Book, because you told it it was a
Product.
And Java is
compiled. You can get away with that sort of stuff in some late-binding languages or scripts that only care about what the
runtime type of the object is; but not in a strictly-typed one like Java.
Winston