Hi everyone,
The following has been bothering me for some time. Suppose we have two classes, Child and Parent, both in the same package, defined as follows:
Class Parent:
Class Child extends Parent:
This prints:
Value of x is: 10
I would think the variable x is inherited from Parent and would lead to a duplicate definition of the same variable in the Child class. After all, you cannot define the same instance variable twice in the same class (the compiler complains about a duplicate field error). Although I am able to access the superclass variable by calling super.x, i'm still confused as to whether this is a case of somehow shadowing a variable or anything.