Hi, I'm studying for the OCA Java SE 7 Programmer I certification exam and was reading chapter 2 and came across the following:
page 103, chapter 2, 8th bullet down of the rules for overriding a method:
The overriding method can throw narrower or fewer exceptions. Just because
an overridden method "takes risks" doesn't mean that the overriding subclass'
exception takes the same risks. Bottom line: An overriding method doesn't
have to declare any exceptions that it will never throw, regardless of what the
overridden method declares.
Then on page 105 of the same chapter in the Exam Watch section it gives the following
example:
Is the error the rule on page 103 I listed above, or is it in the code example in the exam watch section listed in code?
Or am I just losing my mind over thinking this? :-)
Regards,
Joe
page 103, chapter 2, 8th bullet down of the rules for overriding a method:
The overriding method can throw narrower or fewer exceptions. Just because
an overridden method "takes risks" doesn't mean that the overriding subclass'
exception takes the same risks. Bottom line: An overriding method doesn't
have to declare any exceptions that it will never throw, regardless of what the
overridden method declares.
Then on page 105 of the same chapter in the Exam Watch section it gives the following
example:
Is the error the rule on page 103 I listed above, or is it in the code example in the exam watch section listed in code?
Or am I just losing my mind over thinking this? :-)
Regards,
Joe