Win a copy of TDD for a Shopping Website LiveProject this week in the Testing 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Possible Errata for OCP Java SE 11 Study Guide

 
Ranch Hand
Posts: 229
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found some possible errata in the OCP Java SE11 Programmer I Study Guide by Jeanne Boyarsky and Scott Selikoff

Page 385: The last line should read "Since String does NOT implement Canine,...".

Page 409: In table 10.1, for Error type, it is "No" for the question "Okay for program to catch?". Shouldn't this be "Yes" instead? It may be bad practice to catch an Error, but the compiler is not going to complain if you try to catch an Error. After all, an Error is an unchecked exception, and it's okay to catch an unchecked exception. This is demonstrated on page 448 question 22, in which StackoverflowError is a valid type to catch.

Page 445: For question 12, isn't F a correct answer as well since an uncaught NumberFormatException is thrown?
 
Marshal
Posts: 75634
354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please tell us the exact text of the first line you are worried about. Please check here; you have probably found a “new” erratum.
I think thee second question is asking about correct practice; it is usually good practice not to catch Errors, so the book is probably correct.
Please supply the complete text for the third point.
 
author & internet detective
Posts: 41073
848
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

Edmund Yong wrote:Page 385: The last line should read "Since String does NOT implement Canine,...".  


Confirmed an added to the errata list crediting you as the "finder"

Edmund Yong wrote:Page 409: In table 10.1, for Error type, it is "No" for the question "Okay for program to catch?". Shouldn't this be "Yes" instead? It may be bad practice to catch an Error, but the compiler is not going to complain if you try to catch an Error. After all, an Error is an unchecked exception, and it's okay to catch an unchecked exception. This is demonstrated on page 448 question 22, in which StackoverflowError is a valid type to catch.


Not an errata. The column isn't about whether the code will compile. It's about whether you should be doing it.

Edmund Yong wrote:Page 445: For question 12, isn't F a correct answer as well since an uncaught NumberFormatException is thrown?


No. This is a single answer question (note there is not a "choose all that apply"). Option A includes the output and the NumberFormatException. Option F just addresses the exception. Remember that an unhandled exception does result in a stack trace.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jeanne Boyarsky wrote:

Edmund Yong wrote:Page 445: For question 12, isn't F a correct answer as well since an uncaught NumberFormatException is thrown?


No. This is a single answer question (note there is not a "choose all that apply"). Option A includes the output and the NumberFormatException. Option F just addresses the exception. Remember that an unhandled exception does result in a stack trace.



I ended up in this thread cause I'm also convinced that this question contains an error. I understand the argument, that it is a single answer question, but shouldn't be the answers be more clear then?
Apparently there are two objectively correct answers to that question (A and F) but one is "better" than the other. I think the design of the question is not perfect if there is room for interpretation.
 
Bartender
Posts: 1737
63
Eclipse IDE Postgres Database C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch, Michael!

I am often badgering them with arguments over answers, but I think I agree with the authors here.

Answer F. says "An uncaught exception is thrown."
The most meaningful interpretation of this is that "an exception of a type that is not caught anywhere during the stack unwinding terminates the thread in which it was thrown with a stack trace." (I just made that up, there is probably something more formal in the JLS).

That is not occurring here.  The very fact that the 4 appears in the "1234" demonstrates clearly that the exception thrown will be of a type that will be caught in line 9, and handled.

So while, yes, an exception is indeed thrown from the code called at line 7, it is properly caught and handled by the catch block in lines 9 thru 11.

Had that catch block been for an IOException or ClassCastException, or had it been replaced with a finally { } block instead of catch, I would then agree.

There are a fair number of questions that make you want to argue for an alternate answer considerably more than this one should, we will see you when you get up to those.

Enjoy  
 
Michael Gregor
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Jesse for your answer but I think there is some misunderstanding here.

Line 7 throws a NumberFormatException, not a NullPointerException (name is not null as it is set on line 16)! The "4" on Line 10 is never printed as the corresponding catch block only catches NullPointerException (which is never thrown).
Because of this the program stops at Line 7 and answer A is correct: "The output is 12, followed by a stack trace for a NumberFormatException".
But as a NumberFormatException is thrown and not caught anywhere, also answer F would be correct: "An uncaught exception is thrown".

 
Jesse Silverman
Bartender
Posts: 1737
63
Eclipse IDE Postgres Database C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah yes!  I am going to avoid answering these without taking the book down from the shelf in the future.
I usually do that, actually, but was thinking I saw enough context here to skip that step -- I didn't.
 
Every snowflake is perfect and unique. And every snowflake contains a very tiny ad.
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic