Lec23 - Lecture 23 Programming with inheritance(Savitch 7.2 CS125 Course Notes Lecture 23 Slide 1 Recall from last day Animal Mammal Dog CS125

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

View Full Document Right Arrow Icon
CS125 Course Notes Lecture 23, Slide 1 Lecture 23 • Programming with inheritance (Savitch 7.2)
Background image of page 1

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

View Full DocumentRight Arrow Icon
CS125 Course Notes Lecture 23, Slide 2 Recall from last day Animal Mammal Dog
Background image of page 2
CS125 Course Notes Lecture 23, Slide 3 Terminology • A base class is also known as a parent class or the superclass . • A derived class is also known as a child class or the subclass . • An ancestor class is a class that is a parent or parent of a parent (etc.). • If class A is an ancestor of class B, then class B is a descendant class of class A.
Background image of page 3

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

View Full DocumentRight Arrow Icon
CS125 Course Notes Lecture 23, Slide 4 The class Object • Every class in Java extends Object by default. • Provides the basic functionality you see in any object of any type. • No need to extend it explicitly.
Background image of page 4
CS125 Course Notes Lecture 23, Slide 5 Terminology • X is a Y means class X extends Y (or extends an earlier extension of Y). • X has a Y means class X has an instance variable of type Y.
Background image of page 5

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

View Full DocumentRight Arrow Icon
CS125 Course Notes Lecture 23, Slide 6 The Dog class From last day: public class Dog extends Mammal { private String owner; // *** new instance variable *** public Dog() { super(); this.owner = "No owner yet."; this.setSound(""); } public Dog(String name, String theOwner) { super(name, false, "Woof!"); this.owner = theOwner; } // The rest of the class unchanged }
Background image of page 6
CS125 Course Notes
Background image of page 7

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

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 07/27/2009 for the course MATH 135 taught by Professor Andrewchilds during the Fall '08 term at Waterloo.

Page1 / 19

Lec23 - Lecture 23 Programming with inheritance(Savitch 7.2 CS125 Course Notes Lecture 23 Slide 1 Recall from last day Animal Mammal Dog CS125

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

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