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

Sybex 815 - potential error - chapter 11 , Review Question #21

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

chapter 11 , Review Questions

21. Which of the following are legal commands to run a modular
program where n is the package name and c is the class name?
(Choose all that apply.)
A. java –module-path x -m n.c
B. java --module-path x -p n.c
C. java --module-path x -m n/c
D. java --module-path x -p n/c
E. java --module-path x -m n c
F. java --module-path x -p n c
G. None of the above

Appendix answers

21. C. The -p option is a shorter form of --module-path. Since the
same option cannot be specified twice, options B, D, and F are
incorrect. The --module-path option is an alternate form of -p. The
module name and class name are separated with a slash, making
option C the answer.

My question:
Is options C really correct?
I thought the structure of java-command is like this
java -p MODULE_PATH
-m MODULE_NAME_FROM_DESCRIPTOR/AT_LEAST_ONE_PACKAGE_NAME.CLASS_NAME

C.fixed) java --module-path x -m module_name/n.c

So correct is option G.
Or I'm wrong? Thanks for the answer.

PS my another similar question
https://coderanch.com/t/748077/certification/Sybex-potential-error-chapter-Review#3474814
 
Bartender
Posts: 1737
63
Eclipse IDE Postgres Database C++ Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From the help for the java command:

or  java [options] -m <module>[/<mainclass>] [args...]
      java [options] --module <module>[/<mainclass>] [args...]
          (to execute the main class in a module)


Here the docs say <mainclass> to represent:
AT_LEAST_ONE_PACKAGE_NAME.CLASS_NAME

If I were defending them in court, I'd say in the question text where they call c "the class name" they obviously meant "fully-qualified class name".  I think that's what they will say when they see this.

Otherwise, I am confused the same as you.
 
Roman Bohdanov
Greenhorn
Posts: 7
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, Jesse.
I got the point about the fully-qualified class name.
But it still seems to me that there is an inconsistency in the question and the correct answer C :

where n is the package name


and

The module name and class name are separated with a slash, making option C the answer.

 
Jesse Silverman
Bartender
Posts: 1737
63
Eclipse IDE Postgres Database C++ Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah yes.  While it is considered best practice for the packages contained in a module to either have the same name as the module itself, or for the module to be a stem/prefix of the names of the various packages, this is not required.

So n should be referred to as the module name and not the package name.

So while in some cases the module name and the package name will be identical, and in others they will be related, this is not required.

All references to module name should be specified as such, all references to package name should be specified as such.

So we are in agreement here.
 
author & internet detective
Posts: 42003
911
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
Agreed. This should be module name and fully qualified class name.

I checked the Java 17 drafts. We had changed "package name" to "module name". I just changed "class name" to "fully qualified class name"
 
You may have just won ten million dollars! Or, maybe a tiny ad.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic