• 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
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

Sybex Java 8 Appendix A page 564 - Error in answer to question 17

 
Greenhorn
Posts: 4
1
MySQL Database Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A correct answer for question 17 should be D. The import for is missing...

Am I missing something?
 
Saloon Keeper
Posts: 3877
43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't have the book, but I assume your concern is missing imports?
On the exam imports are usually implied and should not be considered as compilation errors.
 
Angel Daniel Alonso Tovar
Greenhorn
Posts: 4
1
MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mikalai Zaikin wrote:I don't have the book, but I assume your concern is missing imports?
On the exam imports are usually implied and should not be considered as compilation errors.



I can share a screenshot of the Oreilly material, if that's allowed... is it allowed?
 
Marshal
Posts: 28009
94
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, that's "fair use" of copyrighted material in this case.
 
Angel Daniel Alonso Tovar
Greenhorn
Posts: 4
1
MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:Yes, that's "fair use" of copyrighted material in this case.



Please see attached...

meow.png
[Thumbnail for meow.png]
 
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
I share your concern.

The full name of AtomicInteger in Java is:
java.util.concurrent.atomic.AtomicInteger

Your screenshot clearly shows a single import line of:
import java.util.concurrent.*;

Which in Java means to import each and every class in the package java.util.concurrent (but not in any sub-packages if any exist).

AtomicInteger is a class, and it lives in package java.util.concurrent.atomic, a "sub-package" of java.util.concurrent

As imports do not include sub-packages, no reference can be made to AtomicInteger without (1) an import of:

(2) an Import of:


(3) or fully qualifying references to it as:

which is rather a mouthful.

The book is published by Sybex, not O'Reilly, but I don't disagree about anything else.
 
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
In general, when they show you a simple code fragment, you are often expected to presume the appropriate import statements are present but omitted from the fragment.

A nice clue they often provide is that line numbers begin with say, 3 or 5 or 6 or 8 or something...

If they show for instance, a package declaration, or any imports, that question is presumably showing you "all the code" and it is reasonable to presume you are supposed to notice the missing import.

In this case, going as far as showing you one import statement, I believe this is intended to represent a full class definition with all provided imports, in the default (unnamed) package, making your complaint correct.
 
Angel Daniel Alonso Tovar
Greenhorn
Posts: 4
1
MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Correct... That's why my concern with the answers...

I mentioned O'reilly because I'm studying the book in that platform.

Please let me know what else should I do to get that added to the errata.

Thank you,
Andelous.
 
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
Likely when either of the authors gets up enough time, they will pop in here and "batch process" threads here relating to their books.

Sometimes we go off on tangents or give confusing advice, however, normally I think the regular folk around here do a pretty good job of welcoming errata posters, and confirming or denying their suspicions / agreeing or disagreeing whether we think something should count as an actual error.

So you probably don't need to do anything further but hurry up and wait.  In the meantime, according to the clues I gave I would definitely consider that an error.  They show at least one import, and a common mistake beginners make is to think importing a package imports its sub-packages.  It does not, or there is no such thing as sub-packages, depending on who you talk to.
 
author & internet detective
Posts: 41775
887
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
Agreed and added to the errata.

I added "Java 8" to the subject of this thread. Most questions at this point are about the Java 11 book. This particular question isn't in the Java 11 book so it took me a while to realize what was going on and find the error!
 
"Don't believe every tiny ad you see on the internet. But this one is rock solid." - George Washington
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic