4 Replies Latest reply: Jan 19, 2007 2:07 AM by 800322 RSS

    Abstract class........

      Dear All,
      " class that defines an abstract method can call that method as well". Please explain its real meaning.
        • 1. Re: Abstract class........
          I have no idea what that's supposed to mean.
          • 2. Re: Abstract class........
            I think it means that you can do this:
            public abstract class Example {
                public doOneThing() {
                public abstract void doAnother();
            because the only way that you could run doOneThing() would be by creating a concrete subclass, thus implementing doAnother().

            However, you should ask the person, who actually said it, what they meant.
            • 3. Re: Abstract class........
              And if you're wondering what could be the use of this, search for the "Template Method" design pattern.

              Basically, a concrete method of the superclass calls a series of abstract methods (different steps) that the subclasses are to implement.

              This way, the superclass controls the flow of execution (by defining the program skeleton) while leaving to the subclasses the freedom (or burden) to implement the list of abstract methods.
              • 4. Re: Abstract class........
                So you can link against a method...

                I mean it's pretty obvious that you can compile using an abstract method. Otherwise the point of having one would be zilch... So I'm wondering whether there's something important or at least less obvious the sentence is referring to.