About Question enthuware.ocpjp.v8.2.1273 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
beaucarnes
Posts: 4
Joined: Sat May 07, 2016 9:58 am
Contact:

About Question enthuware.ocpjp.v8.2.1273 :

Post by beaucarnes »

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?

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

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

Post by admin »

There is no call to open. You should try running the code.

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

dongyingname
Posts: 18
Joined: Sat Jun 22, 2019 4:10 pm
Contact:

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

Post by dongyingname »

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?

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

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

Post by admin »

dongyingname wrote:
Tue Aug 06, 2019 5:26 pm
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?
Because it is not a try block. It is a try-with-resources block.
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 89 guests