public class Foo {
void doStuff() {}
}
class Bar extends Foo {
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 refrence 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.
Refrence: SCJP Sun® Certified Programmer for Java™ 6 Study Guide Exam (310-065)
No comments:
Post a Comment