• 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

Errata - OCP Java SE 8 Study Guide - Page 497 #3

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think all answers are wrong, because the code does not compile, it has an unhandled IO-Exception with Files.newdirectoryStream(Path)
At least in my IDE, so i think all of possible answers are wrong.
 
author & internet detective
Posts: 41871
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
I merged your stuff with the following thread. I hope that is okay by you.
 
Thomas Roth
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is similar to some other erratas i found.

Answer must be B,D because there is also an unhandled IO-Exception from Files.readAttributes() in line 2 of the code snippet.
With this handled, the answer would be only D like it tells.
 
Jeanne Boyarsky
author & internet detective
Posts: 41871
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
No. Oracle has a disclaimer that you should assume the necessary context:

Code fragments: A code fragment is a small section of source code that is presented without its context. Assume that all necessary supporting code exists and that the supporting environment fully supports the correct compilation and execution of the code shown and its omitted environment.



This means if the code isn't in a method, you can assume it declares any checked exceptions. You will see this technique on the real exam too so glad it came up here!
 
Jeanne Boyarsky
author & internet detective
Posts: 41871
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
I merged your stuff with the following thread. I hope that is okay by you.
 
Thomas Roth
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The code snippet will not compile because "Files.deleteIfExists(path) has an unhandled IO-exception.
So the correct answer would be F, NOT B,C
 
Thomas Roth
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jeanne Boyarsky wrote:No. Oracle has a disclaimer that you should assume the necessary context:

Code fragments: A code fragment is a small section of source code that is presented without its context. Assume that all necessary supporting code exists and that the supporting environment fully supports the correct compilation and execution of the code shown and its omitted environment.



This means if the code isn't in a method, you can assume it declares any checked exceptions. You will see this technique on the real exam too so glad it came up here!



Puh, thank you very much Jeanne, i would have missed that in the exam. Really glad it came up here too
So, if no method is shown, all exception handling is done. Good to know! Thank you.
 
Jeanne Boyarsky
author & internet detective
Posts: 41871
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

Thomas Roth wrote:Puh, thank you very much Jeanne, i would have missed that in the exam. Really glad it came up here too
So, if no method is shown, all exception handling is done. Good to know! Thank you.


Correct. And I'm really glad you asked so you don't lose points for this on the real exam!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic