ch11 - Java Programming Fourth Edition Chapter 11...

Info iconThis preview shows pages 1–13. Sign up to view the full content.

View Full Document Right Arrow Icon
Java Programming Fourth Edition Chapter 11 Introduction to Inheritance
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Java Programming, Fourth Edition 2 Objectives Learn about the concept of inheritance Extend classes Override superclass methods Understand how constructors are called during inheritance
Background image of page 2
Java Programming, Fourth Edition 3 Objectives (continued) Use superclass constructors that require arguments Access superclass methods Learn about information hiding Use methods you cannot override
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Java Programming, Fourth Edition 4 Learning About the Concept of Inheritance Inheritance – Mechanism that enables one class to inherit behavior and attributes of another class – Apply knowledge of general category to more specific objects
Background image of page 4
Java Programming, Fourth Edition 5 Learning About the Concept of Inheritance (continued) Unified Modeling Language (UML) – Consists of many types of diagrams Class diagram – Visual tool – Provides overview of a class
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Java Programming, Fourth Edition 6 The Employee Class Diagram
Background image of page 6
Java Programming, Fourth Edition 7 Class Diagram Showing the Relationship Between Employee and EmployeeWithTerritory
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Java Programming, Fourth Edition 8 Learning About the Concept of Inheritance (continued) Use inheritance to create derived class – Save time – Reduce errors – Reduce amount of new learning required to use new class
Background image of page 8
Java Programming, Fourth Edition 9 Learning About the Concept of Inheritance (continued) Base class – Used as a basis for inheritance – Also called: • Superclass • Parent class
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Java Programming, Fourth Edition 10 Learning About the Concept of Inheritance (continued) Derived class – Inherits from a base class – Always “is a” case or example of more general base class – Also called: • Subclass • Child class
Background image of page 10
Java Programming, Fourth Edition 11 Extending Classes Keyword extends – Achieve inheritance in Java – public class EmployeeWithTerritory extends Employee Inheritance one-way proposition – Child inherits from parent, not other way around Subclasses more specific • instanceof keyword
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Java Programming, Fourth Edition 12 Overriding Superclass Methods Create subclass by extending existing class
Background image of page 12
Image of page 13
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 37

ch11 - Java Programming Fourth Edition Chapter 11...

This preview shows document pages 1 - 13. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online