next up previous contents
Next: Inheritance Relationship: Person assoc. Up: Lecture 2: Classes, Objects, Previous: Inheritance Relationship: Vehicle abstract,

Commentary

An abstract class cannot have any objects or instances, but it can have subclasses which may be abstract or concrete. UML uses tag {abstract} below the name in the name compartment of the class. Also the name is given in italic. An abstract class has normally abstract operations. An abstract operation has only signature but no implementing method in the class where the operation is specified. In UML an abstract operations name is given in italic and its signature is followed by the tag {abstract}. A class with at least one abstract operation must be an abstract class. The abstract operations are implemented in subclasses. Thus drive() abstract operation of vehicle is implemented in its subclasses car, boat, truck. Concrete classes can be instantiated into objects. All their operations have implementations in the class. However these operations may be redefined in its subclasses, though their signatures must remain the same. All instances of a subclass will use the operations (with their new definitions if changed). Subclasses allow new attributes, operations and associations to be added to those inherited from the superclass. This possibility of using newly defined methods in subclasses for the operation inherited from the superclass is called polymorphism. Discriminators specify the basis for inheritance, e.g., the characteristics inherited. For example vehicles may be subclassed on the basis of methods used for propulsion or on the basis of number of wheels. Java uses extend to create subclass.


next up previous contents
Next: Inheritance Relationship: Person assoc. Up: Lecture 2: Classes, Objects, Previous: Inheritance Relationship: Vehicle abstract,
Ananda Amatya
11/3/1999