August 2010
Intermediate to advanced
492 pages
13h 39m
English
In Chapter 5, we have seen how to define a class and the various kinds of members that can be defined in a class. Let us now look at how we can create a sub-class of a given class in Java. A sub-class always inherits the functionality of the super-class and can always add more functionality. A sub-class is created when it can be represented by an ‘is a’ relation. There are many examples of super-class and sub-class relationships in the real world, e.g. Car is a sub-class of Vehicle. This is so since Car is a Vehicle. The two types Vehicle and Car are related using the ‘is a’ relationship. Let us look at how to define a sub-class in Java.
For the purpose of understanding the sub-classing ...
Read now
Unlock full access