Hi,
I know we can't create an object for an interface. But the I am very confused with the flow of the below program.
[CODE]
class A{}
class B extends A implements E{} //line 1
class C extends A{}
class D extends B{}
interface E{}
public static void main(
String args[])
{
A a = new D(); //line 2(I know this, we creating the subclass
object with super class refernce)
C c = new C(); //line 3
E e = (E)a; // line 4 (What we are doing in this step)
B b = (B)e; // line 5 ( - do - )
}
}
To select: a. The code compiles without error and runs fine.
b. Compilation error on line 1 because interface E is not yet declared(forward-referencing)
c. The cast on the line 4 is mandatory
d. The cast on the line 5 is not mandatory.
What is forward-referencing?