On this statement:
An overriding method cannot exhibit behavior that contradicts the declaration of the original method. An overriding method therefore cannot return a different type (except a subtype) or throw a wider spectrum of exceptions than the original method in the superclass.
I think the part in red is wrong, you can throw any unchecked exception or error (not a good practice though) from the overriding method.
Am I right?
About Question enthuware.ocajp.i.v8.2.945 :
Moderators: Site Manager, fjwalraven
-
- Posts: 5
- Joined: Mon Feb 15, 2016 5:43 am
- Contact:
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.945 :
Unchecked exceptions i.e. RuntimeExceptions and Errors are not required to be declared at all. So, yes, they can be thrown by any method anytime but that is not really relevant here.
We will add this point to the explanation to make it clear.
Thank you for your feedback.
Paul.
We will add this point to the explanation to make it clear.
Thank you for your feedback.
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 5
- Joined: Mon Feb 15, 2016 5:43 am
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.945 :
I was not very clear on my comment too. The text in red is not wrong, i wanted to say it can be better making it more clear.
Thanks.
Thanks.
Who is online
Users browsing this forum: No registered users and 18 guests