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

    Abstract class........

    807607
      Dear All,
      " class that defines an abstract method can call that method as well". Please explain its real meaning.
        • 1. Re: Abstract class........
          800322
          I have no idea what that's supposed to mean.
          • 2. Re: Abstract class........
            807607
            I think it means that you can do this:
            public abstract class Example {
                public doOneThing() {
                    doAnother();
                }
                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........
              807607
              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........
                800322
                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.