Rahul KumarIndia

Greenhorn
+ Follow
since Jul 26, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Rahul KumarIndia

I know this is too late to answer this post but this is for others looking for this topic.

First of all whenever a constructor is called than the first thing to be called is the constructor of the base class.
If the coder has implicitly provided a call to the constructor than the called constructor will be invoked.
Else the default constructor will be called.
Remember default construcor has no argument list.
So in this case the constructor for Base ith no argument will be called.

Second why add in Extension is called ?
this is because the object instance created is of Base but object reference passed is of Extension. So when a method will be called it will be searched in Extension class first because of its reference.
Even when you are in any function of Base but call to add(...) will call add(...) in Extension.
This is the game of object reference.
Hope it will help
If I am at any point wrong please correct me.
Bye
17 years ago