overriding "parents" (super's) variables and methods. See
Panel for API info available concerning inheritance
what do most Models of applications extend?
Classes (and programs in general) might import a lot, but probably not a lot
of hierarchy
Some (pretty good) slides for Ch. 8 about inheritence and classes from the text. You should be able to do the exercises at the back of the chapter. In these slides, I had gone too quickly over these issues
Show
structure chart page
You will need to start making Object Models in lab 5
Below, Cow is a subclass of Animal. Which knows more?
Scope
methods, instance, super, etc (private and public)
Class Hierarchy
notice extend Applet (GUI)
Object Models
polymorphism
Signatures : The name and parameter type list for a method is called the method's signature. In Java, the return type is not part of the signature. (explains above) (Core Java, Volume 1, page 153)
Other sources however, say return type is part of the signature. (also here and nutshell and again )
Discuss uses (i.e., it is an object-oriented programming conceptual thing around before java (yes, there was a time), and how it is/was used is not dependent on java).
Casting
Do not worry about this too much...you will know when you need it.
You probably won't need it until CSCI 311.
This is an example of type promotion. animal is what daisy
is BUT it will only have access to the facts about Animals
since it is delared as an Animal.
daisy remains a Cow
The only reason that animal can be cast as a Cow, is that animal was
initially created with
Animal animal = daisy;
and daisy was a cow. Normally one can cast up the hierarchy
(a Cow can be cast as an Animal) but you can only cast down
(to subclasses) if the object was initially one of those things.
Again, think about this....why would this be so?
super
Wrap-around methods
also seen in Constructors ...but just a call to super()...
Inheriting from Class Libraries
Don't forget to import
final
Cannot subclass a final class
Cannot override a final method
Cannot change a final variable