1Z0-819 Modular Development & Deployment Practices 5 — Questions and Answers
Question 1: Which `jlink` plugin reduces the size of the runtime image by removing debug information from class files?
- --compress
- --strip-debug (Correct answer)
- --no-header-files
- --exclude-resources
Correct answer: --strip-debug
`--strip-debug` removes debugging information (such as variable names and line numbers) from class files to reduce image size.
Question 2: A named module `com.util` exports `com.util.api` but not `com.util.internal`. A class in `com.util.internal` is needed by a test on the class path. Which option allows reflective access without modifying module-info.java?
- --add-exports com.util/com.util.internal=ALL-UNNAMED
- --add-reads com.util=ALL-UNNAMED
- --open com.util/com.util.internal
- --add-opens com.util/com.util.internal=ALL-UNNAMED (Correct answer)
Correct answer: --add-opens com.util/com.util.internal=ALL-UNNAMED
`--add-opens` grants deep reflective access (private members included) to a package; `ALL-UNNAMED` targets code on the class path (the unnamed module).
Question 3: What does `jdeps --check <module-name>` report?
- Missing requires clauses for undeclared transitive dependencies
- Unused exports and requires in the module's descriptor (Correct answer)
- Compile-time errors in the module-info.java
- Split package violations in the module graph
Correct answer: Unused exports and requires in the module's descriptor
`jdeps --check` compares the module's declared dependencies against its actual usage and reports unused `requires` or missing ones.
Question 4: When using `--module-path` and `--class-path` together, how does the JVM resolve type conflicts where the same class exists on both?
- The module path always wins
- The class path always wins
- Named modules on the module path take precedence over the unnamed module (class path) (Correct answer)
- The JVM throws an ambiguity error at startup
Correct answer: Named modules on the module path take precedence over the unnamed module (class path)
Named modules on the module path shadow any class with the same name on the class path, because named module types are never loaded by the unnamed module's class path.
Question 5: Which statement correctly describes an `open module` declaration?
- The module exports all its packages for compile-time use
- The module allows deep reflection on all its packages at runtime but exports none publicly unless explicitly stated (Correct answer)
- The module is readable by every other module without a requires clause
- The module skips module resolution during JVM startup
Correct answer: The module allows deep reflection on all its packages at runtime but exports none publicly unless explicitly stated
An `open module` grants reflective access to all packages at runtime (equivalent to `opens` on each package) but does not change compile-time export visibility.
Question 6: What naming convention does the module system use to derive the name of an automatic module from a JAR filename like `commons-lang3-3.12.0.jar`?
- commons.lang3 (hyphens become dots, version suffix stripped) (Correct answer)
- commons-lang3 (name used verbatim without extension)
- commonslang3 (all separators removed)
- commons_lang3 (hyphens become underscores)
Correct answer: commons.lang3 (hyphens become dots, version suffix stripped)
The automatic module name is derived by stripping the version suffix and replacing hyphens (and other non-alphanumeric characters) with dots.
Question 7: Which `javac` option specifies the root directories containing module source code when compiling multiple modules at once?
- --module-path
- --source-path
- --module-source-path (Correct answer)
- --root-path
Correct answer: --module-source-path
`--module-source-path` tells `javac` where to find the source tree organized by module directories when performing multi-module compilation.
Which `jlink` plugin reduces the size of the runtime image by removing debug information from class files?