Computer Science Fundamentals (CS153 2003S)
[Skip to Body]
Primary:
[Front Door]
[Current]
[Glance]
-
[EC]
[Honesty]
[Instructions]
[Links]
[Search]
[Syllabus]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Lab Writeups]
[Outlines]
[Readings]
[Reference]
ECA:
[About]
[Grades]
[Quizzes]
[Submit Work]
[Change Password]
[Reset Password]
Misc:
[Experiments in Java]
[Scheme Reference]
[Scheme Report]
[CS153 2002S (Walker)]
[CS151 2003S (Rebelsky)]
[CS152 2000F (Rebelsky)]
[SamR]
Back to Designing Objects. On to Polymorphism.
Held: Wednesday, 9 April 2003
Summary: Today we consider inheritance, one of the key aspects of object-oriented design.
Notes:
whatin
Think about what couses you've takenis a pronoun.
Overview:
subclass.
superclass.
multiple inheritance.
DrawableObject class
and refine that to particular drawable objects, such as Circle
or Square.
Integer
is a Number.
extends keyword (rather than some variant of
is-a.
public class Circle
extends DrawableObject {
...
} // Circle
public class Integer
extends Number {
...
} // Integer
DrawableObject obj = new Circle(); Number n = new Integer(5);
public void drawWithStrangeColors(DrawableObject obj) {
...
} // drawWithStrangeColors(DrawableObject)
...
public Number add(Number val1, Number val2) {
...
} // add(Number,Number)
...
drawWithStrangeColors(new Circle());
...
Number result = add(new Integer(5), new Integer(2));
extends clause,
Java assumes that your object extends java.lang.Object.
super(parameters) as the first line of your
class.
collection of coursesobject.
Back to Designing Objects. On to Polymorphism.
[Skip to Body]
Primary:
[Front Door]
[Current]
[Glance]
-
[EC]
[Honesty]
[Instructions]
[Links]
[Search]
[Syllabus]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Lab Writeups]
[Outlines]
[Readings]
[Reference]
ECA:
[About]
[Grades]
[Quizzes]
[Submit Work]
[Change Password]
[Reset Password]
Misc:
[Experiments in Java]
[Scheme Reference]
[Scheme Report]
[CS153 2002S (Walker)]
[CS151 2003S (Rebelsky)]
[CS152 2000F (Rebelsky)]
[SamR]
Disclaimer:
I usually create these pages on the fly
, which means that I rarely
proofread them and they may contain bad grammar and incorrect details.
It also means that I tend to update them regularly (see the history for
more details). Feel free to contact me with any suggestions for changes.
This document was generated by
Siteweaver on Tue May 6 09:20:58 2003.
The source to the document was last modified on Thu Jan 16 15:16:15 2003.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS153/2003S/Outlines/outline.39.html.
You may wish to
validate this document's HTML
;
;
Check with Bobby