early vs late binding

Discussion in 'Java' started by shaun.86, Dec 19, 2005.

  1. shaun.86

    shaun.86 Guest

    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?
     
    shaun.86, Dec 19, 2005
    #1
    1. Advertising

  2. shaun.86

    Roedy Green Guest

    On 18 Dec 2005 17:40:01 -0800, "shaun.86" <> wrote,
    quoted or indirectly quoted someone who said :

    >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.
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
     
    Roedy Green, Dec 19, 2005
    #2
    1. Advertising

  3. shaun.86

    Guest

    shaun.86 wrote:
    > 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
     
    , Dec 20, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ThunderMusic

    Plugins and Late Binding

    ThunderMusic, Jan 27, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    855
    Patrice
    Apr 12, 2005
  2. Stu
    Replies:
    1
    Views:
    590
    Arne Adams
    Dec 18, 2004
  3. Olaf Meding

    MS COM early and late binding

    Olaf Meding, Apr 27, 2004, in forum: Python
    Replies:
    4
    Views:
    406
    Simon Brunning
    Apr 28, 2004
  4. Replies:
    2
    Views:
    863
    Kevin Grover
    Oct 20, 2006
  5. RN1

    Late & Early Binding

    RN1, Mar 18, 2008, in forum: ASP .Net
    Replies:
    1
    Views:
    603
    Anthony Jones
    Mar 19, 2008
Loading...

Share This Page