File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Associate Certification (OCAJP 7/8) and the fly likes Question about Mala Gupta's Mock exam question #12 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Associate Certification (OCAJP 7/8)
Bookmark "Question about Mala Gupta Watch "Question about Mala Gupta New topic

Question about Mala Gupta's Mock exam question #12

Winston Liek
Ranch Hand

Joined: Jan 19, 2014
Posts: 171
The question says:

Which of the following statements are correct? (Select 3 options)

a You may not be able to handle all the checked exceptions in your code.
b If required, you can handle all the runtime exceptions in your code.
c You can handle an exception in your code even if you don’t know its exact name.
d A single exception handler can be used to handle all types of runtime and
checked exceptions.
e You must handle all errors that can be thrown by your code.
f Runtime exceptions are also known as checked exceptions.

the correct answers are B,C,D

My question is, isn't it A also correct?
Since 'handle' means catching exceptions, if you were not able to handle it, you can 'declare' it, right?
Rico Felix
Ranch Hand

Joined: Mar 08, 2014
Posts: 406

I am thinking to myself it was not included in the correct answers because of the fact that checked exceptions are supposed to be handled in code even if a method declares it, it will still have to be caught along the lines somewhere. That was the main design of the exception handling mechanism so that offending blocks of code can be identified and handled with a logical and systematic approach.
Roel De Nijs

Joined: Jul 19, 2004
Posts: 7913

The wording of answer A is a little bit unclear. It's also the only one of the possible answers with a negation in the statement. And it's always harder to assess a negative statement than a positive one.

I guess it should be interpreted as "there are checked exceptions in your code which can not be handled". Of course that statement would be incorrect, because every checked exceptions can be handled by adding a catch block. But maybe answer A should be read as "it's not needed to handle (using the catch block) all the checked exceptions in your code". This interpretation would be true, because I can declare (as in "adding a throws clause to the method) the checked exception to every method in the method call stack (including the main method).

I'll contact the author of the book and ask Mala if she could chime in and share her thoughts.

SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
I agree. Here's the link:
subject: Question about Mala Gupta's Mock exam question #12
It's not a secret anymore!