Multiple Inheritance Using Java

Multiple inheritance is not supported in Java. Therefore, youll need to use level inheritance whenever you want a class to inherit from two or more other classes. Remember that each class must pass the is a test. Any class that fails this test should not be used in level inheritance.

Java instead provides interfaces, which can in some ways act or seem like multiple inheritance. However, an interface is best thought of as something like a purely abstract class. That is to say, it declares the names of member functions but doesnt actually provide any reusable code from which you can employ inheritance. If you implement an interface in a Java class, you must create all the needed code yourself for those functions. For this reason, interfaces are not really a part of inheritance.

Interfaces should really be considered a set of promises. If a class implements an interface (and therefore contains all the code needed to implement it), then other objects can communicate or work with the class via the interface.

OOP Demystified
OOP Demystified
ISBN: 0072253630
EAN: 2147483647
Year: 2006
Pages: 130

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: