1Z0-819 Modular Development & Deployment Practices 3 — Questions and Answers
Question 1: What is the unnamed module in the Java Platform Module System?
- A module explicitly declared with no name in module-info.java
- A virtual module that contains all classes loaded from the class path (Correct answer)
- The bootstrap module used during JVM startup
- A module whose exports are accessible to every other module
Correct answer: A virtual module that contains all classes loaded from the class path
The unnamed module is a synthetic module that groups all types loaded from the class path, enabling backward compatibility with pre-module code.
Question 2: A `module-info.java` contains `opens com.example.impl to com.framework;`. What does this enable?
- Compile-time access to com.example.impl from com.framework only
- Deep reflection into com.example.impl exclusively by com.framework at runtime (Correct answer)
- Public API export of com.example.impl to com.framework
- Service loading of types in com.example.impl by com.framework
Correct answer: Deep reflection into com.example.impl exclusively by com.framework at runtime
A qualified `opens` grants the specified module the ability to use deep reflection (including private members) on the opened package at runtime.
Question 3: Which file format does `jmod` create, and what is it primarily used for?
- A .jar file optimized for the module path
- A .jmod file used for packaging modules for jlink and distribution (Correct answer)
- A .war file containing modular web applications
- A .zip file for archiving module source code
Correct answer: A .jmod file used for packaging modules for jlink and distribution
`jmod` creates `.jmod` files that can bundle native code, config files, and legal notices alongside classes — primarily consumed by `jlink` to build runtime images.
Question 4: How does the Java module system handle split packages (the same package name in two named modules)?
- It merges the packages at runtime automatically
- It throws an error at module resolution time — split packages are not allowed between named modules (Correct answer)
- It uses the first module found on the module path
- It logs a warning but continues execution
Correct answer: It throws an error at module resolution time — split packages are not allowed between named modules
Split packages between two named modules are illegal; the module system rejects them during resolution with a `LayerInstantiationException` or startup error.
Question 5: Which `java` flag prints a module's descriptor including its requires, exports, and provides declarations?
- --show-module-resolution
- --describe-module (Correct answer)
- --list-modules
- --print-module-info
Correct answer: --describe-module
`--describe-module <module-name>` prints the full module descriptor showing all directives declared in its `module-info`.
Question 6: What is an automatic module?
- A module generated automatically by the compiler when no module-info.java exists
- A non-modular JAR placed on the module path that is given a derived module name (Correct answer)
- A JDK platform module loaded by the bootstrap class loader
- A module whose dependencies are resolved automatically at compile time
Correct answer: A non-modular JAR placed on the module path that is given a derived module name
When a non-modular JAR is placed on the module path, the system creates an automatic module with a name derived from the JAR filename and it can read all other modules.
Question 7: A module `com.app` has `requires java.sql;` in its descriptor. At runtime, which other module does `java.sql` implicitly require via `requires transitive`?
- java.logging
- java.xml
- java.naming (Correct answer)
- java.transaction
Correct answer: java.naming
`java.sql` declares `requires transitive java.logging` and `requires transitive java.xml`, but `java.naming` is the third transitive dependency that consumers of `java.sql` gain.
What is the unnamed module in the Java Platform Module System?