Instance Member variable are overwritten not overridden java

Member variable are not overridden, they are overwritten.

  1. In subclass member variable to be available they need to be either protected/public.
  2. Instance member variable of subclass hide the variable of super class. e.g. parent.variable will call variable of parent and child.variable will call variable of child. See example given below.

    Example 2: