posted 26 years ago
Java uses only single inheritance. This means that each class can have only one direct "parent" class. It doesn't prevent a class also having a "grandparent" class, or several classes sharing the same "parent" class. As an example consider the following class structure from the java.io package:
class Object the base ancestor class, has no "parents"
class Reader extends Object has Object as "parent"
class BufferedReader extends Reader has Reader as "parent", Object as "grandparent"
class InputStreamReader extends Reader also has Reader as "parent", Object as "grandparent"
class FileReader extends InputStreamReader and so on...
As I hope you can see, even limiting each class to a single "parent" class still allows for a complex and useful inheritance structure.
Multiple Inheritance (not supported in Java) is a technique where each class can have more than one direct "parent". Most of the benefits of this approach are available in Java by using interfaces and the "implements" keyword.