First I know this is quite dirty job, and if there is a way, it may be consider "bad practice". Unfortunately, I have to explore the possibility.
I would like to know if I can cast an object that in practice implements a Interface but in fact do not. I mean, the class implements all the methods but do not have the "implement interface" in the declaration. Additionally, I would prefer to do this and finally get the Object typed. Example below
interface IA{
void method();
}
class CB{
    void method(){;}
}
public class foo{
    public static void main(String[] args){
    /*magic to cast the object without exception*/
    IA ob= (IA) new CB(); 
    ob.method(); 
    }
}
I want to get this IA object at the end.
 
     
     
     
     
    