Hi this is the Question from Hardtest
Question
Suppose we have two classes defined as Follows
class Apbase extends Object implements Runnable
class Apderived extends Apbase implements Observer
Given two variables created as Follows
Apbase aBase = new ApBase();
ApDerived aDer = new ApDerived();
which of the Followinf
java statements will compile and execute without error?
a. Runnable rn = aDer;
b. Runnable rn2 = (Runnable) aBase;
c. Observer ob = aBase;
d Observer ob2 = (Observer) aBase;
answers given are a and b
But i guess only the correct answer is b,
Becuase my question is when a ADer is upcasted to Runnable rn all the implemented methods Observer cannot be accessible from Runnable rn.hence i assume the answer 'a' will be Wrong??
Please correct me if i am wrong??