您的位置:寻梦网首页编程乐园Java天地Core JavaJava Lecture Notes

Introduction

Content

Apply

Reflect

Extend

previous.gif
 (3087 bytes)

next.gif
 (2959 bytes)


Extend Index

Extend Page # 3

Multiple inheritance 

It is often possible to reason about a class as if it were a direct subclass of 2 or more classes – for example a Lecturer class might be a subclass of Employee and a subclass of Student (since a lecturer might be registered for some part time course, for example). Some object-oriented modelling and programming approaches allow a class to have multiple inheritance by allowing 2 or more direct superclasses for the same class. This can lead to efficient and elegant class hierarchies. It can also lead to ambiguous inheritance decisions and more complex design and programming.

One of the strengths of Java is that by only having simple class hierarchies, where each class as only a single direct superclass, many potential problems of clashes where an attribute or operation could be inherited from 2 or more superclasses are completely avoided. Single inheritance languages do generally provide mechanisms to support some of the advantages of multiple inheritance – such as the interface mechanism provided by Java.

The advantages and disadvantages of multiple inheritance are still being debated, however for this module, by choosing to focus on a single inheritance programming language, such debates can be put on one side to simplify the process of learning object technology and its implementation in Java.

Back to top

 basicline.gif (169 bytes)

RITSEC - Global Campus
Copyright ?1999 RITSEC- Middlesex University. All rights reserved.
webmaster@globalcampus.com.eg