• 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
  • Ron McLeod
  • Junilu Lacar
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • Carey Brown
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • fred rosenberger
  • salvin francis

type of binding

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
by default what is the type of binding in java, is it static or dynamic binding,how it is handled/
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There was another thread on this question down the page a bit. Late binding refers to the runtime process of figuring out what method to run. Consider some simple thing like this:

List is an interface defined in the JDK. The compiler is assured that myList will point to an object that really implements List so it's happy to let me call size(). But the compiler can't know what code will be executed in size() because the interface has no code at all and myList doesn't point to any object at compile time. Later while running (late binding) the JVM looks at the actual object that myList points to, finds the size() method and runs that code.
I hope it's clear that using an interface like List will force late binding. Inheritance can also force it. The class of the object that myList points to might not actually implement size(). It might extend another class that implements size(). So at runtime the JVM would look first at the class of the actual object, not find a size() method, look at the ancestor class, find a size() method and run it.
In the early days of OO languages there was much debate about whether late binding and dynamic lookup could ever perform well enough to use. I think they have it down pretty good now that desktop computers run thousand of times as fast
[ March 03, 2004: Message edited by: Stan James ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic