Overload or Override?



When am I overloading or overriding a method, and when am I generating compilation errors? The two basic cases here are for examining two methods from the same class, and two methods where one is from a subclass of the other.

The following tables show what occurs for all the possibilities. Assume that table entries left blank are irrelevant given what has already been decided.

Two Methods From The Same Class

name parameter
list
result
different will make a completely different method
same same compilation error
same different overload


One Method From A Superclass And One From A Subclass

name parameter
list
parent
class
visibility
modifier
is private
child
class
visibility
modifier
as least as
visible
as parent
class
return
type
result
different will make a completely different method
same different overload
same same yes will make a completely different method
same same no no compilation error
same same no yes different compilation error
same same no yes same override