Please do not steal other's post. If you have questions to ask, make a new thread.
Even you should not have answered him.
To answer Balakrishna's original question, methods are called based on the runtime object. So, at runtime, the variable obj has an object of Derived class. So, Derived class' method will be called. But the compiler looks for method based on the type of the variable. So, if you declare a method in base class, the compiler will compile and at runtime, the actual object's method will be called.