Just now I started to learn object reference conversion and casting.Looks like I got it when I work out in paper.But I need to work it in computer.Its showing the error I need to make the ApBase and ApDerived classes as abstract.but the question given is like
class ApBase extends Objects implementsRunnable
class ApDerived extends ApBase implements Observer
//Following variables created from above classes
ApBase aBase = new ApBase();
ApDerived aDer = new ApDerived();
which of the following compile and run w/o error ?
A) Object obj = aBase;
Runnable rn obj;
B) Object obj = aBase;
Runnable rn = (Runnable)obj; ..........Answer
C) Object obj = aBase;
Observer ob = (Observer)aBase;
D) Object obj = aDer;
Observer ob2 = obj;
why do I need to make those classes abstract.If I make it abstract then abstract classes won�t instantiate like this
ApBase aBase = new ApBase();
ApDerived aDer = new ApDerived();
Please help me to execute the above program.