To my understanding, if type checking can be done during compilation, the type casting will be done during compilation and will not incur any runtime overhead.
For example
public Child getChild() {
Parent o = new Child();
return (Child) o;
}
Is the type casting done during compilation or during runtime?
And is there any general rule to decide if a type casting is done by javac compiler or by the VM?