Consider following code:
Theoretically, the call at line no. 13 should not cause any error as
count is defined for testObj as a field in
SubClass, but it gives a
Cannot create property count on SubClass. Interestingly if we move
modifyProperty method to
SubClass or make
count public, it works without any error.
So it can be said that we cannot access protected fields dynamically in a subclass.