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

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: 41855
904
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.
 
Saloon Keeper
Posts: 15445
362
  • 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
Saloon Keeper
Posts: 15445
362
  • 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: 41855
904
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic