Saturday, October 9, 2010

Inheritance important Points in java

If a Super(Base) class contains a Method 'setName(String name)'
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:

AWS certification question

AWS AWS Hi! this is for questions related to AWS questions. EC2 instances EC2 storage types cold HDD : 1. Defines performance in terms...