I read dynamic binding happens when the class of the object that calls the method is not known till runtime can someone give an example of such a situation
Here is a good explanation to clarify your doubts.
linus dale wrote:Dog is subclass of Animal my doubt is,finally, doggie is object of class Dog or of class Animal ?
It's an object of type Dog.
if doggie is an object of Dog, doggie.show will obviously call show method of Dog and not Superclass Animal
(because of method overrriding,if I am not wrong)
Yes. That's exactly what happens here.
When you say
It creates an object of type Dog which is referenced by a reference of type Animal called doggie.
Campbell Ritchie wrote:It is also an object of the Animal class.
This shows dynamic binding, but also shows the hazards of hiding fields. You can get confused because both Dog and Animal classes have a "type" field.
also i wanted to know what all the signature of a method includes
name of method,no. of arguments,data type of arguments
and return type(I am not sure about return type)