posted 21 years ago
Well in the first A extends B, so methods and and variables exposed in B will be available in A.
So (if you had made variables public or from within the same package) A.x is valid and returns 5 in the first example, but not valid in the second.
The other thing is that B b is a local variable in the constructor, so even if you get the new instance of B, it will be released the moment the constructor is done. In order to keep B around, you would have to make B a global variable in the class.