This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
I am no expert, but I am pretty sure that the JVM looks for a method in the class that is calling it. If it can't find it, it looks in the superclass and so on and so forth until it reaches object. An overriden method would be reached before the superclasses method. An overloaded method is a method with the same declaration but different parameters. So the JVM is looking for the one with the parameters you specify?
When you say other features of polymorphism what do you mean? One might be a subclass can be used any time a superclass is needed. [ November 22, 2007: Message edited by: colton peterson ]
Originally posted by colton peterson: That would be a case of overloading. If you wanted overiding everything would have to be the same.
Well not anymore. Java 5.0 introduced a new feature (can't think of the name*), which allows you to downcast the return type - you can return any type as long as it is a subclass of the return type of the original method.
This can be very useful for cloning:
The reason this is allowed is because any calling class expect something of the original method's type (Object in the example). Any subclass will respect that expectation.
* Just remembered: it's called covariant return. [ November 22, 2007: Message edited by: Rob Prime ]