[Solved] Convertible or not?


You can only cast a reference if there is an “is a” relationship. There is no “is a” relationship between A and B. A is a C, and B is a C, but B is not an A.

Consider: Both apples (B) and oranges (A) are fruit (C), but apples are not oranges.


Note: In Java, “conversion” means “turning something into something else.” You can convert a String to an int, for instance, via Integer.parseInt. That’s not what the casting operator does; the casting operator just changes the type of reference you have to a thing, not the actual thing.

solved Convertible or not?