is there any possibility that o1 or o2 can be casted to A and the program will run? Why is the last statement a runtime error?
public class A{
public A(Object object)
{
}
public A(){
}
public String toString(){
return "A";
}
}
public class Main{
public static void main(String []args){
A a4 = new A();
Object o1 = new Object();
Object o2 = new A(o1);
a4 = o1; //Compilation error
o2 = o1;
((A)o1).toString();//Runtime error
a4.toString();
((A)o2).toString();//Runtime error
}
}