Howdy ranchers,
Ahmed Yehia posted
Its always possible to cast to interface type unless the object is of final class.
The reason why this is allowed is that you could extend a non-final class and additionaly implement this interface.
To allow a polymorphic use of these kind of classes, the cast must be legal.
Example: When you additionally to Jchq and Bicyle compile this:
It also compiles and there is no exception. It prints:
MountainBike Bicycling
By the way, not related: Eclipse 3.1
IDE warns us about class Bicycle: "This method has a constructor's name".
Yours,
Bu.