• 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

Looking for Exceptions when working with the exam test questions.

 
Greenhorn
Posts: 22
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all, my question comes up right after i finished the test after NIO2 chapter (9) in the OCP Study Guide by Boyarski and Selikoff.  As there are multiple methods that potentially throw a checked IOException , i got confused in some answers as it appears the potential exceptions are not taken into consideration.

Examples : question 6 uses a Files.walk() method , but has no try/catch, question 17 uses .toRealPath() which no try/catch , isSameFile() in multiple other questions and so on  .So basically i realized my expectation is different than what the questions are actually about.

So i have 2 questions :
1. Best way to determine whether i should care for checked exceptions handling or not on a question?
2. If there is a compilation error due to not handled exception , what line should it it be marked on? The line where the method is , the line where its encompassing method is, or somewhere else( in case the lines a remarked //1 //2 and so on and there is a choice)? It should be the the one the compiler shows, but just to be sure.


Thanks
 
Claude Sylvanshine
Greenhorn
Posts: 22
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And i just saw this topic.
https://coderanch.com/t/667713/java-programmer-OCPJP/certification/Errata-Chapter-Java-OCP-Programmer

i guess it answers my question. For some reason i never had this doubt in any previous chapter or at OCA.
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Claude, those questions are code snippet without line numbers they could throw away the exception to the caller..
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Claude,
You found the answer already. For anyone else, the exam objectives contain this text:



Consider code without a method to be a fit. You don't have to think about try/catch blocks!

I'm not surprised you first noticed this in ch 8 or 9. Checked exceptions are quite prevalent in ch 8,9 and 10. So it comes up a lot more.
 
He got surgery to replace his foot with a pig. He said it was because of this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic