This has got to be one of the most frequently misunderstood topics in
Java. All you have to do is write some
test programs and see what happens when you try to compile:
A) Object obj = aBase;
Runnable rn = obj;
The compiler sees that you are trying to cast a reference to Object to a Runnable type. The compiler DOES NOT KNOW OR CARE that the preceeding line assigned a compatible reference to obj.
You MUST get the difference between what happens at compile time and what happens at run time straight.
B) Object obj = aBase;
Runnable rn = (Runnable) obj ;
The compiler sees that you are deliberately casting obj to type Runnable and assumes that you know what you are doing. At RUNTIME the cast will be checked and if obj is not Runnable, a ClassCastException will be thrown.
Bill