About Question enthuware.ocpjp.v8.2.1613 :

All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.

Moderators: Site Manager, fjwalraven

Post Reply
dhartman0172
Posts: 1
Joined: Sun Aug 07, 2016 9:00 pm
Contact:

About Question enthuware.ocpjp.v8.2.1613 :

Post by dhartman0172 »

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"

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v8.2.1613 :

Post by admin »

Yes, any method can declare any unchecked exception in its throws clause. The restriction about subclass is only for checked exceptions.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

rolandl
Posts: 1
Joined: Sun Jun 05, 2016 12:01 pm
Contact:

Re: About Question enthuware.ocpjp.v8.2.1613 :

Post by rolandl »

So, the explanation of question/answer is not correct ....

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v8.2.1613 :

Post by admin »

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!
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 23 guests