This week's book giveaway is in the Functional programming forum.
We're giving away four copies of Functional Design and Architecture and have Alexander Granin on-line!
See this thread for details.
Win a copy of Functional Design and Architecture this week in the Functional programming 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Sybex Study Guide 1Z0-815 Page 486 Review Question #7

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have a question about review question #7 on page 486 of the Study Guide for exam 1Z0-815.

The review question asks:

Suppose module puppy depends on module dog and module dog depends on module animal. Which two lines allow module puppy to access the animal.behavior package in module anima? (Choose two)



The correct answer according to page 526 are D (requires on line T) and G (requires transitive on line S).

As I see it, the package animal.behavior can never be accessed from within module puppy directly, because it is only exported explicitly to module dog.
I have the following code:







When compiling the puppy module, I get the following error


When I change the module-info.java from module animal so that it only reads "exports animal.behavior" (without the "to dog" at the end). The code runs successfully and prints "behave!".
Am I missing something?
 
author & internet detective
Posts: 40746
827
Eclipse IDE VI Editor Java
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Christian,
You are correct. This is an error. Adding to the errata now. (It shouldn't say "to dog")
 
Christian Schulz
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jeanne,

thanks for your reply. Glad I understood it correctly.
 
Greenhorn
Posts: 1
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Shouldn't be considered?

Putting transitive or not, the requires does import the dog module.

Making "G and H" a valid option either.  
 
Saloon Keeper
Posts: 1230
38
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

Gerson Freitas wrote:Shouldn't be considered?

Putting transitive or not, the requires does import the dog module.

Making "G and H" a valid option either.  



I agree.  If Gerson and myself are not confused, this was an example of a question that posed three correct answers and told us to choose two.

While the requires transitive says more than what is needed, it would as far as I can see compile fine and work fine for this purpose.

Whether it would be necessary for the overall situation or not would only be known by seeing more information than given in the problem, but it would certainly be sufficient to allow puppy to access animal.behavior.

The tests are already so full of tricks, this is rough.  Either three answers should be accepted (and in fact required) or one of either the requires transitive dog or requires dog choices should be removed.
 
Jeanne Boyarsky
author & internet detective
Posts: 40746
827
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
This particular question says "choose two." We all agree on one of them> That leaves you deciding between which of the requires is the best choice. I would argue that the more specific one is better.

Jesse: Where's your lawyer hat?
 
My favorite is a chocolate cupcake with white frosting and tiny ad sprinkles.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic