Automatic Module Naming from JAR File
Short answer
C The automatic module name for display-ascii-0.2.jar is display.ascii, formed by stripping the version and replacing hyphens with dots.
Question
Key Takeaways
Tests the Java Platform Module System (JPMS) rule for generating automatic module names: remove .jar, strip version numbers, replace non-alphanumeric characters with dots.
Determines the automatic module name generated for a JAR file lacking a module-info.java. Establishes that 'display-ascii-0.2.jar' resolves to 'display.ascii' by stripping version and suffixes and replacing hyphens with dots.
Common mistake: Selecting option D ('display-ascii-0.2') because it assumes the full filename is used, or selecting A/B due to incorrect handling of versioning or special character replacement rules.
Expert Analysis
Why the Answer Is Correct
According to the JPMS specification, when a JAR file on the module path does not contain a module-info.class, an automatic module name is derived from the JAR file name. The process involves removing the .jar extension, stripping any trailing version number (like -0.2), and then replacing any remaining non-alphanumeric characters (such as hyphens) with dots (.). Therefore, display-ascii-0.2.jar becomes display-ascii-0.2, then display-ascii-0 after version removal (note: strictly speaking, the spec says "trailing sequence of digits and hyphens" often acts as version, but typically 0.2 is considered part of the version identifier in Maven-style naming). Wait, let's look closer. The standard rule is: remove .jar. Then remove any trailing version string (digits and hyphens). display-ascii-0.2 -> remove .2? No, usually 0.2 is the version. If we assume standard Maven coordinates, display-ascii is the artifact ID. The version is 0.2. So we strip -0.2. Remaining: display-ascii. Replace - with . -> display.ascii. This matches Option C.
Why the Other Options Are Wrong
Option A (display-ascii-0) fails to replace the hyphen with a dot. Option B (display-ascii) fails to recognize that while the hyphen is removed/replaced, the specific transformation logic leads to dots for separators. Option D (display-ascii-0.2) uses the raw filename without applying JPMS naming conventions.
Community Comment Notes
The community unanimously agrees on Option C. Users like zuluitai and Tojose explicitly note that special characters are replaced with dots and version numbers are stripped. One user referenced Jeanne Boyarsky's book, confirming this is a standard exam topic.
Exam Strategy
Memorize the JPMS automatic module naming algorithm: Strip .jar, strip version suffix, replace non-alphanumerics with dots. Practice with common Maven-style filenames to build intuition.
Frequently Asked Questions
How does JPMS handle version numbers in automatic module names?
Why is display.ascii correct instead of display-ascii?
Community Votes
100% of anonymous learners picked answer C. Votes are pick records left by other test-takers — they are not the verified answer.
Discussion 6 contributions
Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.
From public community threads 6
-
zuluitai 👍 3The correct answer is C. After removal of .jar, the version number '0.2', and trailing special character '-' The remaining special characters in between letters is replaced with a dot(.) Thus the automatic name will be 'display.ascii'
-
Tojose 👍 2the right answer is C. display.ascii becasuse java converts any special characters in in the name to dots
-
supersquax 👍 1I agree with toulose! option C correct
-
9817c20 👍 1C according to jeanne boyarsky book
-
Handyana 👍 2 Answered Cagree, C is right answer
Show 1 more comment
-
xplorerpj 👍 1C is right answer
Reader comments & corrections
No reader corrections yet — spotted an error or have a note? Share it below.