I couldn't understand that either, until I tried to compile the code (both ways) and found that it compiled perfectly well (both ways).
However when I tried to run the code, it runs perfectly well because the compile was successful. In the one case the runtime (not the compiler) outputs that error message you posted, and in the other case it didn't output anything.
So you're confusing compiling code with running code. Hope that clears up the confusion.
Joined: Jun 25, 2012
Okay, I am using RAD so I guess I couldn't distinguish compile error vs runtime error.
Still, why doesnt it produce a runtime error when a = null ?
Yes, that's right. And remember that the compiler doesn't make any attempt to analyze the code (as you did there). All it officially knows about the variable "a" is that it was declared as type "A". It doesn't look at anything other than that.