Ankit Garg wrote:please Use Code Tags when you post a source code. You can edit your message using button and then add code tags to it.
Line 15 is just a normal downcast. m is downcasted to C and automatically upcasted to B (Since class B implements Min and C extends B, thus C IS-A Min). Line 17 is tricky. But suppose the reference m points to an object of type B, then the object pointed by m will be assignable to a reference of type A (as B IS-A A). That's why the cast is allowed. So the fact is, a cast between an interface and a non-final class is always allowed. That's because there might be a class that implements that interface and extends that class. Again line 18 is just a normal downcast. Line 19 downcasts b2 to type C and then it is automatically upcasted to Min. Line 20 is also a normal downcast...