Matthew Brown wrote:
Ashish Dutt wrote:
There is no problem in compiling the aforementioned code. It compiles and runs fine. What I'm trying to understand is the logic that undergoes in the above code!! Please refer to the question asked in the original post
Well, yes, now you've posted different code it will compile. You need to be precise about the question you're asking - the missing bits might be important. And you still haven't told us what the output is. I'm asking for clarification because it's not entirely clear to me what the original question was really asking.
Okay the rephrased question again is as follows:
Why is it that the reference variable super1 of SuperClassExp not able to access the instance variable of subClassExp even though it has been assigned to it using the assignment operator. as
With the above assignment done The reference variable super1 is only able to access superclVar using the dot operator. I want to know why it cannot access the intstance variable named
even though it has been assigned the SubClass.