posted 21 years ago
In addition to the previous posts, I offer two other thoughts.
First, it is perfectly normal and valid for an abstract class to contain non-abstract (i.e., fully implemented) methods, static or otherwise. An abstract class can include as much implementation as is appropriate. This is one thing that differentiates an abstract class from an interface.
Second, defining a static method inside an abstract class enables that method to be called independently of any object. Thus, a static method of an abstract class can be called without there being any instances of a concrete subclass in existence.
Here is a rather contrived example that illustrates these two points.
The output is shown here.
Number of objects that include A: 0
Number of objects that include A: 1
Number of objects that include A: 2
[ October 10, 2003: Message edited by: Herb Schildt ]
For my latest books on Java, including Introducing JavaFX 8 Programming, see HerbSchildt.com