public class Foo { public void doStuff(int y, String s) {} public void moreThings(int x) {} } class Bar extends Foo { public void doStuff(int y, long s) throws IOException {} }
It's tempting to see the IOException as the problem, because the overridden doStuff() method doesn't declare an exception, and IOException is checked by the compiler.
But the doStuff() method is not overridden! Subclass Bar overloads the doStuff() method, by varying the argument list, so the IOException is fine.
Refrence: SCJP Sun® Certified Programmer for Java™ 6 Study Guide Exam (310-065)
No comments:
Post a Comment