File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "query" Watch "query" New topic


Kartik Mahadevan
Ranch Hand

Joined: Feb 16, 2005
Posts: 47

Could anyone plz explain the term latebinding ?
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.

Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
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
Kartik Mahadevan
Ranch Hand

Joined: Feb 16, 2005
Posts: 47
Thanks Stan James

I understood your point.

I agree. Here's the link:
subject: query
It's not a secret anymore!