Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

nikojava Mock question

 
Bartender
Posts: 543
4
Netbeans IDE Redhat Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Dieter Quickfend
Bartender
Posts: 543
4
Netbeans IDE Redhat Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, question #27:

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?
 
Dieter Quickfend
Bartender
Posts: 543
4
Netbeans IDE Redhat Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Ranch Hand
Posts: 252
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dieter,

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).

- Nidhi
 
Creator of Enthuware JWS+ V6
Posts: 3348
303
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dieter,

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.....

Regards,
Frits
 
Dieter Quickfend
Bartender
Posts: 543
4
Netbeans IDE Redhat Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Argh, you're right. Extremely sorry. I should get some more sleep. Thank you!
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic