Inheritance problem (JAVA) [closed]

Here I have created 2 classes , $A$ is the super class of $B$ , i.e , $B$ inherits the features of class $A$.

Now I don't know exactly what statement (1) does but I am speculating as follows ,kindly correct me if I am wrong ,

An object of $B$ is created whose address has been assigned to the variable $ob$ of class $A$.

Now when statement (2) is called the $add$ function of the class $B$ is executed , but when statement (3) is executed it gives an error saying $e$ doesn't belong to $A$. Why is that ?

With my understanding , I thought statement (1) creates an object of class $B$ via its parent class $A$. Then why its object can't access its data member ? Can anyone explain ?

• We discourage images as the main content (relevant parts should be transcribed into text). Strictly programming questions are off-topic here. Java tag is not used here in the context of the code debugging.
– Evil
Oct 25 '16 at 16:03
• Sorry. A new user here. Will keep that in mind. Thanks ! @Evil Oct 25 '16 at 18:48

The variable $ob$ is an object reference variable of type $A$. As such, it can only reference those attributes and methods defined in $A$. The attribute $e$ is defined in $B$, not $A$, so $ob$ cannot reference $e$. It is okay to reference $add$ because it is defined in $A$, even though it is overridden in $B$.