Fellas !! I have a doubt in class Hierarchy!! Please Help me !!
Here we are supposed to find at which line an exception is thrown
I think it should be line 14 but thats not the answer. Thats because if it would have been B b=new C(); then we could have written b=(C)m but the line is B b=new B();
This example is taken from Devaka Coorey !!
At line // 1: b is a reference of type B, and you are trying to assign it a reference of type C (which points to null.) Since C is a subtype of B, this will not be a problem.
All code in my posts, unless a source is explicitly mentioned, is my own.
a fool thinks himself to be wise, but a wise man knows himself to be a fool - shakespeare. foolish tiny ad:
Gift giving made easy with the permaculture playing cards