Sridhar,
Both
System.out.println (an.numberOfLegs);
and
System.out.println (this.numberofLegs);
will equally work fine(Because, you can directly access the protected member variable either with the instance variable or thru inheritance). It didn't work in your code because, of case-sensitive nature of Java. If you check the initial post by Ngozi, above he is printing back "an.numberofLegs" and not "an.numberOfLegs".
Cheers,
Rama