The code which you have provided doesn't work at all coz you want to access subclass related thing with Superclass reference. It will directly give you compile time error if it is not in super class....