Hi Suren,
What you're seeing is the result of the way
Java resolves references at runtime. Static members are resolved using the
declared type. Non-static, or instance members, are resolved using the
actual type.
In your example, the object 'bc' is declared as type 'BaseClass' and created using 'SubClass'. Because <code>sayHello()</code> is
static, the JVM resolves the reference to <code>sayHello()</code> using the declared type BaseClass.
Below I've modified you're code and added a new non-static method, <code>sayGoodbye()</code> in both the BaseClass and SubClass.
The output is:
Hope that helps.
------------------
Jane
The cure for boredom is curiosity.
There is no cure for curiousity.
-- Dorothy Parker