Created
January 19, 2014 05:41
-
-
Save rajeevprasanna/8500874 to your computer and use it in GitHub Desktop.
overloading without overriding
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package polymorphism.overloadingWithoutOverriding; | |
public class Bar extends Foo { | |
// Don’t be fooled by a method that’s overloaded but not overridden by a | |
// subclass. It’s perfectly legal to do the following: | |
void doStuff(String s) { | |
} | |
// The Bar class has two doStuff() methods: the no-arg version it inherits | |
// from Foo (and does not override), and the overloaded doStuff(String s) | |
// defined in the Bar class. Code with a reference to a Foo can invoke only | |
// the no-arg version, but code with a reference to a Bar can invoke either | |
// of the overloaded versions. | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package polymorphism.overloadingWithoutOverriding; | |
public class Foo { | |
void doStuff() { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment