Automatic Module Naming from JAR File

1Z0-829 By islever Editorial Last updated

Packaging and deploying Java code and use the Java Platform Module System

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

Assume you have an automatic module from the module path display-ascii-0.2.jar. Which name is given to the automatic module based on the given JAR file?
  1. display-ascii-0
  2. display-ascii
  3. display.ascii Correct Answer
  4. display-ascii-0.2

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?

Version numbers (typically trailing digits and hyphens) are stripped from the filename before transforming special characters.

Why is display.ascii correct instead of display-ascii?

JPMS requires that all non-alphanumeric characters in the resulting name be replaced with dots to form valid module names.

More 1Z0-829 FAQ →

Community Votes

C
100%

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

  1. zuluitai 👍 3
    The 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'
  2. Tojose 👍 2
    the right answer is C. display.ascii becasuse java converts any special characters in in the name to dots
  3. supersquax 👍 1
    I agree with toulose! option C correct
  4. 9817c20 👍 1
    C according to jeanne boyarsky book
  5. Handyana 👍 2 Answered C
    agree, C is right answer
Show 1 more comment
  1. xplorerpj 👍 1
    C is right answer

Reader comments & corrections

No reader corrections yet — spotted an error or have a note? Share it below.

Log in to comment, report an error, or add a note about this question.

← Back to 1Z0-829 Study Guide