• 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
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

OCP IZO-809 IO Review Question 10 (Sybex)

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Book : Oracle Certified Professional Java SE8 Programmer 2 (IZO-809)

I have a question regarding Chapter 8(IO): Question 10  (pg 447).

 


A. It can delete a directory that contains only files
B. It can delete a directory tree of arbitrary length
C. It can delete a single file. -
D. It compiles but may throw an exception at runtime

The book says that C and D are correct answer but from what the code is doing, it looks like it's able to delete recursively all the files. So to me, looks like the code can delete a directory tree of any arbitrary lenght, it's just that it can't delete the directory itself.

Am I failing to understand something ?
 
author & internet detective
Posts: 39399
763
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mohit,
Welcome to CodeRanch! I've added the publisher name to the subject (a number of books have similar sounding names.)

My copy of the book lists C and F as answers to #10. We have an errata that F is debatable. But D was never a correct answer. Can you double check that your book does say D for that question. (And if so, can you post a picture that contains the page # and that answer?
 
Mohit Acharya
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jeanne,

Thanks for the quick reply, and i'm sorry i did not post the question properly the first time. I'm attaching the answer pictures in this thread.

You are correct, that D : The code will not compile because of line 2 was never the answer because the code compiles without any issue. My only question was regarding C : It can delete a single file. While it can delete a single file, the code can also recursively clean the entire directory as well. That's where the answer C (It can delete a single file ) confused me.

So while i think that C is correct, I want to make sure that i'm reading the code snippet correctly when i'm saying that it's able to also recursively delete "ALL" the files in the directory as well. In other words, i fail to see how the code snippet could only delete only a single file in the directory.

My apologies for the confusion once again.

Thanks
Mohit
IO_Q10_answer.jpg
[Thumbnail for IO_Q10_answer.jpg]
 
Jeanne Boyarsky
author & internet detective
Posts: 39399
763
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mohit,
I"m pleased your copy of the book matches mine and says "C and F." (There was a recent thread where the reader's copy was different than mine. It turned out the publisher had incorrectly fixed an errata.)

Anyway, back to C. Suppose you call the method with new File("/my/path/a.txt"). It will delete a.txt because the else block will run.
 
Mohit Acharya
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jeanne,

That does make sense. No i see what the question was trying to make me understand.

Appreciate your quick response.
BTW, do you have a list of all the erratas that have been submitted for this book ? i was thinking it would be in the Sybex website (https://testbanks.wiley.com) but i'm not able to find it there.

Thanks once again.
Mohit
 
Jeanne Boyarsky
author & internet detective
Posts: 39399
763
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's on our website. The publisher's list is incomplete.

http://selikoff.net/ocp
 
Rancher
Posts: 137
7
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is exactly how I go about it. I'm currently going through the book and have the website open all the time. So, in case of doubt, I can easily look it up.  
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That interest topic
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!