2 Replies Latest reply: Jun 5, 2007 4:30 AM by 807606 RSS

    regarding dynamic binding and abstract class

    807606
      Hello Java Community,

      In dynamic biniding consept, it binds the appropriate method at run time... can any one please give me the reason how it identifes that perticular method is nearst one.....( i know that it first check sub class and then goes to super class ....... i just want how it identifys this process).....

      As per java soft new release JDK1.5 we can also write abstract class with out implimenting methods(even partially also) ... in this case if i declare all methods in abstract class were "public abstract " (like in interface methods return type) it will be similar as interface ......... and i just want in this case what is the difference between interface and abstrace class
        • 1. Re: regarding dynamic binding and abstract class
          807606
          Hello Java Community,
          Hi
          In dynamic biniding consept, it binds the
          appropriate method at run time... can any one
          please give me the reason how it identifes that
          perticular method is nearst one.....( i know that it
          first check sub class and then goes to super class
          ....... i just want how it identifys this
          process).....
          Basically, there are two things Class and object.
          Class defines a particular structure.
          And Object is a real instance of that structure.

          Now Objects are stored in a Heap. You need a reference to access them.

          Now the variable that refer to that object could be of the same structure or any Parent of that structure.

          Now object is responsible for doing something(changing state, or performing some action), not the structure through which you refer to it.

          I think things would be clear now.
          As per java soft new release JDK1.5 we
          can also write abstract class with out implimenting
          methods(even partially also) ...
          This was possible in earlier versions as well.

          in this case if i
          declare all methods in abstract class were "public
          abstract " (like in interface methods return type)
          it will be similar as interface ......... and i
          just want in this case what is the difference
          between interface and abstrace class
          The difference would be in your stategy.
          If you foresee, that you could have to give default implementation to the methods later, then this option is open for you in Abstract class.
          Also you could define constructors in an abstract class.

          Otherwise it would better to implement an interface, as the option of extending another class would be open for you.

          But I think Interfaces are better for defining raw structure of an application, because defining a structure is a managerial issue, and implementing that structure is a technical issue. Those two shouldn't be intermixed.

          But as I said earlier it depends on you requirements, which way to go.
          • 2. Re: regarding dynamic binding and abstract class
            807606
            hello Sumit.Tyagi

            Thanks Q for responding...... and thanks for clearing my doubt....

            Regards
            sricharan