Venkatesh said:
I think static methods don't show polymorphic behavior because static
methods are bound to classes.
Yep.
But, when f1 is called from a reference to an object of base, then f1
in base class is called and if f1 is called from reference to an object
of derived, then f1 in derived class is invoked.
First of all, it's moderately broken (but technically legal) to call f1
using a reference in the first place. The compiler in Eclipse can be
set up to give you an error or warning when you do it, and CheckStyle
can do the same. These are good things. The correct way to call f1 is
as follows:
BaseC1.f1(); OR
DerivedC1.f1();
In either case, it's clear which of the two methods is being called.
Remember, just say not to calling static methods using a reference.
--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation