in the contrary, an abstract class "must" be subclassed. The reason why people make classes abstract is that they want the subclasses (of the abstract class) to implement their behavior.
Let's say we have a class Vehicle with a method drive() in it. You cannot tell how to drive a vehicle. That's why you have to let the subclasses of Vehicle (Car,Ship,Aircraft,...) implement that behavior, and in terms of implementation it is done like this:
As you can see, abstract classes are a way of specifying the interface of a class but letting the subclasses implementing their behavior. This way you can have, for instance, an array of Vehicle and invoke the drive method on its elements without even having to care about what type of Vehicle is in the Array. This is called
Polymorphism.
As you can see, we can reference Cars, Ships, ... with a Vehicle reference because a Car is_a Vehicle and a Ship is_a Vehicle too.
Moreover, we don't instantiate a Vehicle directly, but we instantiate its subclasses (Car and Ship). You cannot call new Vehicle() but you can call new Car() and new Ship() because the latter two are concrete classes.
HIH
------------------
Valentin Crettaz
Sun Certified Programmer for
Java 2 Platform
[This message has been edited by Valentin Crettaz (edited December 10, 2001).]