Skip to main content Accessibility help
×
Hostname: page-component-7479d7b7d-qlrfm Total loading time: 0 Render date: 2024-07-11T23:25:05.607Z Has data issue: false hasContentIssue false

4 - Relationships between Classes

from PART ONE - FOUNDATIONS

Published online by Cambridge University Press:  05 June 2012

Richard Wiener
Affiliation:
University of Colorado, Colorado Springs
Lewis J. Pinson
Affiliation:
University of Colorado, Colorado Springs
Get access

Summary

We examine two important types of relationships between classes in this chapter – namely, composition and inheritance. We illustrate the concepts by constructing a complete software system in Java that illustrates the use of these two types of relationships.

Inheritance

Inheritance, as the name implies, involves the transmittal of behavioral characteristics from parent class to child class. Through inheritance one can establish behavior in a base class that is available and directly usable in a hierarchy of descendent classes that extend the base class.

As discussed in Chapter 1, inheritance can be centered on factoring and reusing methods (implementation inheritance) or on extending behavior (behavioral inheritance). It is the latter that we shall utilize in this chapter and throughout this book.

With behavioral inheritance, it is essential that any child class logically be of the same type as its parent. As you recall from Chapter 1, the principle of polymorphic substitution allows a descendent class to be used in place of its ancestor. This would make sense only if each child class can logically be considered to be a kind of its parent.

A child class may extend a parent class by introducing one or more fields or methods not found in the parent or by redefining one or more parent class methods.

Type
Chapter
Information
Publisher: Cambridge University Press
Print publication year: 2000

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Save book to Kindle

To save this book to your Kindle, first ensure coreplatform@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

  • Relationships between Classes
  • Richard Wiener, University of Colorado, Colorado Springs, Lewis J. Pinson, University of Colorado, Colorado Springs
  • Book: Fundamentals of OOP and Data Structures in Java
  • Online publication: 05 June 2012
  • Chapter DOI: https://doi.org/10.1017/CBO9780511807176.005
Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

  • Relationships between Classes
  • Richard Wiener, University of Colorado, Colorado Springs, Lewis J. Pinson, University of Colorado, Colorado Springs
  • Book: Fundamentals of OOP and Data Structures in Java
  • Online publication: 05 June 2012
  • Chapter DOI: https://doi.org/10.1017/CBO9780511807176.005
Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

  • Relationships between Classes
  • Richard Wiener, University of Colorado, Colorado Springs, Lewis J. Pinson, University of Colorado, Colorado Springs
  • Book: Fundamentals of OOP and Data Structures in Java
  • Online publication: 05 June 2012
  • Chapter DOI: https://doi.org/10.1017/CBO9780511807176.005
Available formats
×