If you overwrite a field in a subclass of a class, the subclass has two fields with the same name(and different type)?

Member variables cannot be overridden like methods. The number variables in your classes Beta and Gama are hiding (not overriding) the member variable number of the superclass.

By casting you can access the hidden member in the superclass.

Leave a Comment

tech