Hi,
These overrides are not valid since they do not throw the same or subclasses of exceptions. Plus the methods are declared public when they should be protected. Am I wrong? I've seen many questions where the exceptions are not part of the methods signatures and that confuses me although I'm pretty sure they should be there. Am I missing something?
Thanks
About Question com.enthuware.ets.scwcd.v5.2.106 :
Moderator: admin
-
- Site Admin
- Posts: 10102
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question com.enthuware.ets.scwcd.v5.2.106 :
Hello,
This is OCPJP stuff An overriding method is allowed to have no throws clause because no throws clause is a valid subset of exceptions thrown by the overridden method.
Further, an overriding method can increase the visibility of the overridden protected method by making it public.
So the methods are valid.
HTH,
Paul.
This is OCPJP stuff An overriding method is allowed to have no throws clause because no throws clause is a valid subset of exceptions thrown by the overridden method.
Further, an overriding method can increase the visibility of the overridden protected method by making it public.
So the methods are valid.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
Re: About Question com.enthuware.ets.scwcd.v5.2.106 :
Cool, I didn't know that about the exceptions, only the usual "same or narrower".
Thanks for the prompt reply.
Thanks for the prompt reply.
-
- Posts: 60
- Joined: Wed Apr 23, 2014 6:38 pm
- Contact:
Re: About Question com.enthuware.ets.scwcd.v5.2.106 :
Second answer states that at least 1 of the methods would be called. Its blue comment says the answer is wrong because "None of its methods will be called for HTTP - HEAD, PUT, and DELETE requests".
Say a http client (cURL, browser) does just that. It issues an HTTP PUT request, to a servlet that has not been preloaded or preinitialized. Would not the servlet be loaded and the init() method be called? Only after the init() method running the lack of a doPut() method would come into play, with the default doPut() method sending an 405 error code back.
The above would make the second answer OK. This seems seconded by question #scwcd.v5.2.293, where a blue comment states "Notice that init() will also be called for the first request to this servlet".
Thanks for an explanation, if possible.
Say a http client (cURL, browser) does just that. It issues an HTTP PUT request, to a servlet that has not been preloaded or preinitialized. Would not the servlet be loaded and the init() method be called? Only after the init() method running the lack of a doPut() method would come into play, with the default doPut() method sending an 405 error code back.
The above would make the second answer OK. This seems seconded by question #scwcd.v5.2.293, where a blue comment states "Notice that init() will also be called for the first request to this servlet".
Thanks for an explanation, if possible.
-
- Site Admin
- Posts: 10102
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question com.enthuware.ets.scwcd.v5.2.106 :
The 2nd option says "For each and every request...". init will not be called for "every" request but only for the first one.
HTH,
Paul.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 60
- Joined: Wed Apr 23, 2014 6:38 pm
- Contact:
Re: About Question com.enthuware.ets.scwcd.v5.2.106 :
Thanks, I should have grokked that.
Who is online
Users browsing this forum: No registered users and 3 guests