I have a couple issues with this question.
First, the wording suggests there is only one correct answer: "What is the correct way," (singular) not "What are correct ways" (plural). This is misleading since it is actually looking for two options to be selected.
Second, using throws Throwable is an acceptable or possible way that compiles, but I would not call it "the correct way." I would say the correct way would be to declare the actual exception thrown. If it throws more than one, then use the most specific parent class that includes both.
Since the question says that it raises a checked exception, which is therefore a subclass of Exception, that would seem to me like the correct way to declare it. Again, throws Throwable is acceptable and compiles but seems confusing if the method doesn't actually throw Error. It seems like the question should be reworded to ask "what are the possible ways to declare that method so that it indicates that it expects the caller to handle that exception?"
About Question enthuware.ocajp.i.v7.2.1345 :
Moderators: Site Manager, fjwalraven
-
- Posts: 3
- Joined: Sun Jun 03, 2012 5:45 pm
- Contact:
-
- Site Admin
- Posts: 10389
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1345 :
You are right. Fixed.
thank you for your feedback!
Paul.
thank you for your feedback!
Paul.
Who is online
Users browsing this forum: No registered users and 1 guest