posted 19 years ago
An abstract method is nothing more than a declaration. It simply states that any class that wishes to extend this class must override this method and provide its own implementation. Of course, on the other hand, you're free to override any non-static method, abstract or not. Abstract methods, however, must be overridden.
In addition, you can "invoke the abstract method" on a reference of the Superclass type. Take this example:
Why does this work? Well, the compiler knows that the reference variable s can't possibly reference an object of type Super. Why can't it? Super is defined as an abstract class - it can't be instantiated. Therefore, we know that whatever s references at runtime will be a subclass of Super and, because doIt() is an abstract method defined within Super, we know that whatever object s references will have to provide an implementation for that method. With all of that knowledge in hand, we can determine that the polymorphic call will execute safely.