• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Sybex Practice Tests 11 - Chapter 7 Java Platform Module System, Page 252, Question #35

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

The answer for the question 35 in Chapter 7 Java Platform Module System, Page 252, was maybe incorrect, since the "import" keyword can also be used in module-info.java

The given answer in the book was B, to say, only "uses" keyword can be used in module-info.java

Regards
 
author & internet detective
Posts: 42148
937
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 think the book is right. I checked the Java Language Specification and it contains this for modules



Nothing about import.
 
Bartender
Posts: 15741
368
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's because module-info.java is not a ModuleDeclaration. It's a ModularCompilationUnit. A modular compilation unit contains both import declarations and a module declaration.

Import statements in module-info.java are useful when you're referencing type names in the module declaration. Here is an example:
 
Abderrazak Zaouiati
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

Agreed, but the question is "How many of these keywords can be used in a module-info.java file: closes, export,
import, require, and uses?
" there is no reference to "module declaration", the question just asks about keywords that can be used inside module-info.java file, in my opinion import should also be correct
 
Stephan van Hulst
Bartender
Posts: 15741
368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree with you, I was replying to Jeanne.
 
Jeanne Boyarsky
author & internet detective
Posts: 42148
937
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have a cow! I did not know that. I thought you had to have all mentions fully qualified.

I'm not putting this in the errata because the book doesn't cover it.But I making a note for next time.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic