13.7 Summary


13.7 Summary

Abstract classes have one or more abstract methods. An abstract method does not include its implementation, only the function declaration, also known as the function specification. These classes cannot be instantiated; they can only be used as base classes. The subclasses redefine (override) the functions that are abstract in the base class. A pure abstract class has only abstract methods. An interface is similar to a pure abstract class, but it cannot declare attributes. An interface may include constant declarations and may inherit another interface. A class can implement several interfaces.

A base class can be used as a super type, and the subclasses as subtypes. An abstract class can be used as a type of an object variable (object reference). This object variable can be assigned object variables of a subtype. There are normally several object variables of each subtype. It is then possible to invoke a function of an object variable of a subtype. Polymorphism is a language mechanism that selects the appropriate function to execute. This selection is based on late binding. Polymorphism uses the type of the actual object and not the type of the object variable.




Object-Oriented Programming(c) From Problem Solving to Java
Object-Oriented Programming (From Problem Solving to JAVA) (Charles River Media Programming)
ISBN: 1584502878
EAN: 2147483647
Year: 2005
Pages: 184

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