Deepak Bala wrote:
There is no realtionship between Runnable and variable aa which is of type A.
Which would explain the error
Deepak, you forgot, type cast between Interface and Class is always allowed (non-final class to be specific). Simran, the cast is allowed because the cast may be successful at runtime. Here's how
So basically a cast between an unrelated class and interface is allowed because they might have a common subtype (as class B in this case). But a cast between unrelated classes is not allowed because they cannot have a common subtype (as
java doesn't allow a class to extend from multiple classes)...