• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

query

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hii

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.

Thanks
Regards
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Kartik Mahadevan
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Stan James

I understood your point.

Regards
 
I was born with webbed fish toes. This tiny ad is my only friend:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic