Could anyone plz explain the term latebinding ? i.e We can use the same base class refrence to point to diffrent subclasses but when a overrided method is called the execution depends on the refrnced object in the garbage.They call it Latebinding ? How can we say that is runtime binding when the code is written before compiling? Sorry to ask such a silly question but i am puzzled.
I might have a method that takes an argument defined by an interface:
The List interface has no code at all, so the compiler can't possibly generate a direct call right into a method. So at run time (late) it looks at the actual object instance that is passed into the method, binds your call to the object's size() method and calls it.
The class that defines the object that is passed in might not have a size() method. It might extend another class that does have size(). So you can imagine the JRE working its way up the chain of superclasses until it finds the method. In truth, the compiler and the JVM may optimize this search away, but it's still a valid mental picture.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi