• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

IndexOutOfBounds exceptions

 
Greenhorn
Posts: 10
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure how to approach a few questions that I've come across on Enthuware, below is an example of one such question:



It does actually throw a StringIndexOutOfBoundsException but that's not the right answer to the question. I understand the explanation in that the String class itself throws an IndexOutOfBoundsException for this method but really I'not sure how far I should follow this line of thinking when approaching the questions in the exam which I'm due to take next Friday.

Should I memorize exactly which methods throw which exception in the API as opposed to the subexceptions that they throw when run? Can anyone who has done the exam let me know if the OCA questions are similar to this?

 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't worry; you don't have to memorize exception names for the OCA.

The real exam tells you how many answers are correct; just like Enthuware does. This means that if you are torn between too many answers, you clearly have to choose the best ones. In this case, "the index is zero" answer is clearly the best one. So now you have to pick the next best answer. I like going with what is in scope for the OCA. Primitive types are a simple topic so that is way more likely to be correct.

Also, the OCA isn't tricky when it comes to memorizing names. It is tricky with respect to edge cases in logic/syntax. So you need to know whether a catch block is required when there is a finally. Not spotting this is a valid trick. Exact method/exception names, not so much.
 
Simon Miller
Greenhorn
Posts: 10
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for that answer Jeanne.  
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic