February 2014
Beginner
1248 pages
62h 25m
English
Often, an object of one class is an object of another class as well. For example, a CarLoan is a Loan as are HomeImprovementLoans and MortgageLoans. Thus, in Java, class CarLoan can be said to inherit from class Loan. In this context, class Loan is a superclass and class CarLoan is a subclass. A CarLoan is a specific type of Loan, but it’s incorrect to claim that every Loan is a CarLoan—the Loan could be any type of loan. Figure 9.1 lists several simple examples of superclasses and subclasses—superclasses tend to be “more general” and subclasses “more specific.”
Fig. 9.1 | Inheritance examples.
Because every subclass ...
Read now
Unlock full access