Lecture 9 of 12Computer Science A, Spring 2007
PreviousNextOverview

Lecture 9:  Classes and Inheritance

Reading material:

  • Chapter 9

    • Section 9.1-4
    • Section 9.6-8

  • Chapter 11

    • Section 11.1-3

  • Chapter 13

    • Section 13.1-6
    • Section 13.7-8

Exercises:

Slides:

1Chapter 9: Designing classes30An Introduction to Inheritance
2Choosing Classes31Layout of a Subclass Object
3Choosing Classes32Inheritance Hierarchies
4Cohesion33A Simpler Example: Hierarchy of Bank Accounts
5Cohesion34Inheriting Methods
6Coupling35Inheriting Instance Fields
7Coupling36Implementing the CheckingAccount Class
8High and Low Coupling between Classes37Inherited Fields are Private
9Static Methods38Invoking a Superclass Method
10Self Check39Syntax 13.2: Calling a Superclass Method
11Answers40Implementing Remaining Methods
12Static Fields41Subclass Construction
13Static Fields42Syntax 13.3: Calling a Superclass Constructor
14Chapter 11: Interfaces and Polymorphism43Converting Between Subclass and Superclass Types
15Using Interfaces for Code Reuse44Converting Between Subclass and Superclass Types
16Using Interfaces for Code Reuse45Converting Between Subclass and Superclass Types
17Using Interfaces for Code Reuse46Syntax 13.4: The instanceof Operator
18Interfaces vs. Classes47Polymorphism
19Generic DataSet for Measurable Objects48Polymorphism
20Implementing an Interface Type49File AccountTester.java
21Converting Between Class and Interface Types50File BankAccount.java
22Casts51File CheckingAccount.java
23Self Check52File SavingsAccount.java
24Answers53Output
25Polymorphism54Self Check
26Polymorphism55Answers
27Chapter 13: Inheritance56Object: The Cosmic Superclass
28An Introduction to Inheritance57Overriding the toString Method
29An Inheritance Diagram58Overriding the toString Method

You can find a printer-friendly overview here.