- You need to check the run-time receiver for the method before looking for the compile-time object which is the super class.
- Message resolution uses the run-time type of the receiver.
- Flow of control can jump up and down form super to sub-class.
- Don't over-code, just rely on polymorphism.
- When you override the method's arguments need to agree with prototype.
- Java 5 does allow you to change return type on an override as long as it is more specific.
- Do you ever really need to use instanceOf?
- Class can only have one superclass, but can implement multiple interfaces.
- Multiple inheritance is the bain of C++; Java's one superclass + multiple interfaces rules.
- Every object derives from Object.
- Every object has a toString that derives from Object and can be overriden.
- equals is a deep comparison of an object, returns boolean.
- If an object is the the same, then there hash code is the same.
- Make use of an @Override to tell the compiler your are trying to override a superclass method.
- Comparable is just an interface that contains a method int CompareTo(Object o) returns the negative if rcvr/less, 0 if the same, positive if greater.
- Java 5 now has Comparable
. - You must use encapsulation or you will be lost on more complex projects.
- Document your testing strategy.
Chad Salinas