It's question #22 from niko's servlet mock listed in the scwcdmocks section of this site.
The question goes as follows:
What happens when this servlet is compiled and deployed? (1 correct answer)
1. Compilation fails because doGet() is protected.
2. Compilation fails because doGet() does not declare a ServletException.
3. Deployment succeeds and clients are served just fine.
My answer was 2, but the answers list 3 as the correct answer. However, I've checked the API, and doGet throws ServletException, which is a checked exception and no subclass of IOException, so it should be 2, shouldn't it?
Does this servlet compile successfully? (1 correct answer)
1. Compilation succeeds.
2. There is a compilation error at line #1.
3. There is a compilation error at line #2.
4. Both lines #1 and #2 contain a compilation error.
My answer was 3, 'cause println() is a void method, but the answer listed as the correct one is 4.. That's not right, is it? IOException and ServletException are both subclasses of Exception, so Exception will catch either, no?
never mind this. It appears that in all my wrong answers (I got like 12 wrong answers), it is actually the answer listing that is mistaken. That is so confusing.
Anyone have any other, more reliable, mock exams? I really want to do some more mocks before taking my SCWCD, but I don't want to have to pay for them... Already did the Inquisition ones, and the ones from the book...
Are you sure the answers are wrong? Both answers seem right to me. Remember in Java, the overriding method can narrow exceptions (hence the first one is right) but cannot broaden exceptions (hence the second one is right).
"A problem well stated is a problem half solved.” - Charles F. Kettering
SCJP 6, OCPJWCD
I agree with Nidhi on both answers and explanations.
There ar a lot of free mock exams, but the quality is not always good and not to mention about the outdated questions. The one (commercial) mock exam product that will for sure make you pass the exam is the one of Enthuware. The level of difficulty and the way questions are asked is simular to the real exam.....