This content has been marked as final. Show 2 replies
can the grandchild object invoke display() method inNo. The child can explicitly call its immediate parent's methods with super.method() but it can't invoke its more distant ancestors' methods.
base class without invoking the display() method in
the child class i.e its immediate base class
also in object castingNeither. Precision is not an issue for objects.
do we lose or gain precision as in normal type
now in the above three class exampleTry it and see for yourself.
what happens when
base class object is converted intoYou cannot "convert" one object to another class by casting. All casting does is tell the compiler and the runtime to treat a reference of one type as a reference of another type. It does not affect the object at all.
derived class object
and what happens when we convert derived classsAgain: 1) you don't convert objects. 2) try it and see.
object into a base class object