[Skip to Body]
Primary:
[Front Door]
[Current]
[Glance]
-
[Honesty]
[Links]
[Syllabus]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Readings]
[Reference]
Misc:
[SamR]
[Java 1.4.2 API]
[EIJ]
[CS152 2000F]
[CS153 2004S]
Back to Standard Object Methods. On to Exceptions (1).
Held: Friday, 24 September 2004
Summary: Today we consider inheritance, one of the key aspects of object-oriented design.
Related Pages:
Due
Assignments
Overview:
subclass.
superclass.
multiple inheritance.
ColoredPoints, which are points that add colors.
Integer is a Number.
extends keyword (rather than some variant of is-a.
public class ColoredPoint
extends Point
{
} // class ColoredPoint
public class Integer
extends Number
{
...
} // class Integer
public class ColoredPoint
extends Point
{
} // class ColoredPoint
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));
super(parameters) as the first line of your
subclass constructor.
rebelsky.drawing.ColoredPoint class that extends rebelsky.newvec.Point.
Back to Standard Object Methods. On to Exceptions (1).
[Skip to Body]
Primary:
[Front Door]
[Current]
[Glance]
-
[Honesty]
[Links]
[Syllabus]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Readings]
[Reference]
Misc:
[SamR]
[Java 1.4.2 API]
[EIJ]
[CS152 2000F]
[CS153 2004S]
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 Wed Dec 8 10:37:13 2004.
The source to the document was last modified on Thu Aug 26 20:22:22 2004.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS152/2004F/Outlines/outline.17.html.
You may wish to
validate this document's HTML
;
;
Check with Bobby