Inheritance and Interfaces


Both C++ and Java support the powerful object-oriented programming concept known as inheritance that allows a class to build upon the capabilities of another class. Java and C++ differ with respect to inheritance in that Java does not support multiple inheritance. A Java class can have only one direct superclass that itself can have only one direct superclass and so on.

Java partially compensates for its lack of multiple inheritance through a programming construct known as an interface. An interface declares one or more methods that must be implemented by any class that implements the interface. In this way, interfaces are somewhat similar to abstract classes. The interface only specifies the method name , return type, and input parameter list while providing no limitations on what the body of the method will be. How the method is implemented is up to the class that implements the interfaces. Two classes may implement a method declared in an interface in completely different ways. A given class can implement any number of interfaces.



Technical Java. Applications for Science and Engineering
Technical Java: Applications for Science and Engineering
ISBN: 0131018159
EAN: 2147483647
Year: 2003
Pages: 281
Authors: Grant Palmer

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net