The question asks....
Which of the following exceptions can be declared in the throws clause of a method overriding the method:
public void perform_work( ) throws IOException {
//some code
}
one of the correct answers is an NPE.
I don't understand why this is correct. Is it because it is an unchecked exception?
I thought that if an exception of an overriding method was defined it would have to be of "Any Subclass of IOException"
About Question enthuware.ocpjp.v8.2.1613 :
Moderators: Site Manager, fjwalraven
-
- Posts: 1
- Joined: Sun Aug 07, 2016 9:00 pm
- Contact:
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v8.2.1613 :
Yes, any method can declare any unchecked exception in its throws clause. The restriction about subclass is only for checked exceptions.
HTH,
Paul.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 1
- Joined: Sun Jun 05, 2016 12:01 pm
- Contact:
Re: About Question enthuware.ocpjp.v8.2.1613 :
So, the explanation of question/answer is not correct ....
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v8.2.1613 :
Rules are applicable only to checked exceptions. The explanation is talking about additional rule imposed on an overriding method.
Unchecked exceptions have no rules. This has nothing to do with overriding.
Explanation has been added to make it more clear.
thank you for your feedback!
Unchecked exceptions have no rules. This has nothing to do with overriding.
Explanation has been added to make it more clear.
thank you for your feedback!
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: No registered users and 23 guests