About Question enthuware.ocajp.i.v8.2.866 : What can be the type of a catch argument?

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

Moderator: admin

Post Reply
pieterb
Posts: 2
Joined: Sat Sep 04, 2021 10:11 am
Contact:

About Question enthuware.ocajp.i.v8.2.866 : What can be the type of a catch argument?

Post by pieterb »

I don't agree with the provided answers of the following question (Q27 of 69 Standard Tests- Foundation Test):
What can be the type of a catch argument?
- Any class that extends java.lang.Exception
- Any class that extends java.lang.Exception except any class that extends java.lang.RuntimeException
- Any class that is-a Throwable
- Any Object
- Any class that extends Error
The correct answers according Ethuware:
- Any class that extends java.lang.Exception
- Any class that is-a Throwable
The answer "Any class that extends Error" should also be accepted. An error like "ExceptionInInitializerError" can be thrown and caught without problem. Yet it's not good coding practice to do so, but an error can be "the type of a catch argument" without problem!

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

Re: About Question enthuware.ocajp.i.v8.2.866 : What can be the type of a catch argument?

Post by admin »

No, you have to select only one correct option and that option is option 3: Any class that is-a Throwable.

"Any class that extends Error" is not even an option. Option 2 is "Any class that extends Error except any class that extends java.lang.RuntimeException", which is not correct because you can catch RuntimeException.
If you like our products and services, please help us by posting your review here.

marcybr
Posts: 1
Joined: Tue Sep 05, 2023 7:26 am
Contact:

Re: About Question enthuware.ocajp.i.v8.2.866 : What can be the type of a catch argument?

Post by marcybr »

Why "Any class that extends java.lang.Exception" cannot be selected too? Can't any subclass of Exception be in a catch as well?

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

Re: About Question enthuware.ocajp.i.v8.2.866 : What can be the type of a catch argument?

Post by admin »

Yes, if you have to select multiple options then you can select ""Any class that extends java.lang.Exception" but the question asks you to select the best option. The best option is Any class that is-a Throwable.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 35 guests