Hi Jeff, I hv executed this program. Output 10
Output: 10
You can only access a protected variable via inheritance and not via reference variable
Sub class can access super class protected member through inheritance only. and not via superclass variable.
If the child class method uses superclass reference to access the superclass protected member, it will be compilation error.
In the given program extends class is not used, so there is no parent child relation between the classes 'Parent' and 'Child'. Use class main method is calling 'useParent()' (public)method of 'Child' class.
UseParent() method is accessing 'a' (protected member) in 'Parent' class, there is no compilation error because, both the classes 'Parent','Child' both are in same package 'cert'.
A protected member can be accessed by any class in the same package.
[ December 24, 2005: Message edited by: Naresh Kumar ]