Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2005

Tip: Looking for answers? Try searching our database.

early vs late binding

Thread view: 
shaun.86 - 19 Dec 2005 01:40 GMT
Can someone explain the difference between early and late binding?  (ie
- compile time versus run time binding?)  What is the difference
between the two and where would it come into play when coding?
Roedy Green - 19 Dec 2005 02:19 GMT
>Can someone explain the difference between early and late binding?  (ie
>- compile time versus run time binding?)  What is the difference
>between the two and where would it come into play when coding?

It does not normally apply to Java.  Binding happens at class load
time, which is fairly late compared with most other languages.

When you use AOT compilation, (see
http://mindprod.com/jgloss/jet.html) some of the binding happens at
compile time. Only the dynamic Class.forName loading is deferred to
class load time.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

q_q_anonymous@yahoo.co.uk - 20 Dec 2005 06:24 GMT
> Can someone explain the difference between early and late binding?  (ie
> - compile time versus run time binding?)  What is the difference
> between the two and where would it come into play when coding?

"Java uses late-binding to support polymorphism; which means the
decision as to which of the many methods should be used is deferred
until runtime "

"it  is Java's use of late-binding which allows you to declare an
object as one type at compile-time but executes based on the actual
type at runtime "

it's to do with

class A {..}
class B Extends A {  }

A a = new B();

A is a's comiletime type.
B is a's runtime type

here's where i get rusty-

if you do  a.method1();   and method1() is overriden by B, then it'll
run B's

And if method1()  is not overriddden in B, then I think it runs in A -
accesses A's field.

i'm not sure about fields.
I think, if you've overridden a field from A, but you haven't
overridden method1() from A,  then method1 will run in A and use A's
fields. So, running in A, maybe that's compile-time binding.

I don't know about if it deides at runtime to invoke a method or acess
a field from a compile-time class. whether that's compile time binding
or runtme binding


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.