This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Andy James wrote:Why is casting an object of type Person to an unrelated Interface Printable allowed, as follows:
What should the compiler do in this case?
Basically, it is not possible, at the time of the cast, to determine whether the Person reference is referring to a Person object that implements Printable (or not) -- hence, it is allowed at compile time (but will fail at runtime). On the other hand, try making the Person class final, and see what happens.