Automatic Module Naming from JAR File
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?
Community Votes
100% of anonymous learners picked answer C. Votes are pick records left by other test-takers — they are not the verified answer.
Community Insight
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.
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.
Community Discussion (6 comments)
Comments & Corrections
No comments yet — spotted an error or have a note? Share it below.
Expert Analysis
Why the Answer Is Correct
According to the JPMS specification, when a JAR file on the module path does not contain amodule-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.