and a Derived class also Contains a method 'setName(String name)'
with the invocation of method from the object of derived class.will only Invoke the Method in derived Class.
Then How to Invoke a overRidden Method , which is in Base class.
It is possible through the KeyWord "super"
if a Method was Overridden in the Derived Class.
That should have same signature & Return Type as Method in Base Class.
A Derived Class can not access the Private Variables and Private Methods in the Base Class.
A Call to Base Class Constructor Will Automatically done from the Constructor of the derived Class.
if you call Explicitly the Base Class Constructor though by using "Super" Keyword From the Derived Class constructor.then the First line should b in the Derived Class Constructor, is Super();
Just Like Super Keyword (used to Call Constructor of the Base Class) We can call Constructor of the base Class using the keyword "this".
this(parameters to Constructors if any)
and also this should be the first line statement in the Constructor of the Derived Class.
we cannot use keywords 'super' & 'this ' from the static Context.
Functions are not Qualify for Overloading just based on the Return Types,they Should have qualify based on parameters taken .
No comments:
Post a Comment