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 following
Java code fragments will compile and execute without error?
a) Object obj = aBase ;
Runnable rn = obj ;
b) Object obj = aBase ;
Runnable rn = (Runnable) obj ;
c) Object obj = aBase ;
Observer ob = (Observer)aBase ;
d) Object obj = aDer ;
Observer ob2 = obj ;
Can anyone please explain what actually is happening in these 4 options...
And which one is the correct option and why ....
And also what is checked in the compile time and runtime..