About Question enthuware.ocpjp.v8.2.1273 :
Moderator: admin
-
- Posts: 4
- Joined: Sat May 07, 2016 9:58 am
- Contact:
About Question enthuware.ocpjp.v8.2.1273 :
What am I missing in the code for this question? The answer says that it throws a java.lang.Exception but as far as I can tell the code never gets to that point because while opening the resource it throws IOException. So why isn't the answer IOException?
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v8.2.1273 :
There is no call to open. You should try running the code.
HTH,
Paul.
HTH,
Paul.
-
- Posts: 18
- Joined: Sat Jun 22, 2019 4:10 pm
- Contact:
Re: About Question enthuware.ocpjp.v8.2.1273 :
My question is not really related to the topic here:
I knew a try-block must be followed by a catch or a finally or both. But why the single try-block in the main method is successfully compiled?
I knew a try-block must be followed by a catch or a finally or both. But why the single try-block in the main method is successfully compiled?
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v8.2.1273 :
Because it is not a try block. It is a try-with-resources block.dongyingname wrote: ↑Tue Aug 06, 2019 5:26 pmI knew a try-block must be followed by a catch or a finally or both. But why the single try-block in the main method is successfully compiled?
Who is online
Users browsing this forum: Bing [Bot] and 7 guests