I have 3 files to test this.
//A.java
public class A {
public void method(){
System.out.println("In A");
}
}
//B.java
public class B extends A {
public void method()
{
System.out.println("hello world");
}
}
//mymain.java
import A;
import B;
public class mymain{
public static void main(String args[])
{
B b=new B();
A a=new A();
b = (B)a;
b.method();
}
}
Since this requires an explicit cast I did just that
But I get a runtime error
Exception in thread "main" java.lang.ClassCastException: A
at mymain.main(Compiled Code)
Any help?????
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]