โ† All OCP Flashcard Decks

Java Platform Module System Flashcards

7 cards from real OCP practice questions. Tap to flip, then mark Knew It or Still Learning โ€” missed cards come back until you master them.

Read the first 7 Java Platform Module System flashcards as text
  1. Which directive in module-info.java allows a module to expose a package for deep reflection at runtime without exporting it for compile-time access?

    Answer: opens

    The `opens` directive allows reflective access to a package at runtime but does not export it for use at compile time.

  2. What happens when a module declares `requires transitive com.utils;` and another module depends on that module?

    Answer: Downstream modules automatically read com.utils without declaring requires

    `requires transitive` implies readability, so any module that reads the declaring module also automatically reads com.utils.

  3. Which tool is used to create a custom runtime image that contains only the modules needed by an application?

    Answer: jlink

    `jlink` assembles a set of modules and their dependencies into a custom, minimal JVM runtime image.

  4. A module named `com.app` contains package `com.app.internal`. Which declaration restricts its export to only `com.trusted` module?

    Answer: exports com.app.internal to com.trusted;

    The `exports ... to` qualified export restricts which specific modules can access the exported package.

  5. Which command-line option allows code in an unnamed module to access a package from a named module that does not export it?

    Answer: --add-exports

    `--add-exports` overrides module boundaries at runtime or compile time to expose a package that is not otherwise exported.

  6. What is the term for a JAR placed on the module path that does not contain a module-info.class?

    Answer: Automatic module

    A JAR on the module path without module-info.class becomes an automatic module, deriving its name from the JAR filename.

  7. Which of the following statements about split packages is TRUE in the Java Module System?

    Answer: The same package cannot exist in two named modules on the module path

    The JPMS strictly prohibits the same package from being present in two different named modules; this causes a module resolution error.