nerdexam
Oracle

1Z0-819 · Question #31

Examine this excerpt from the declaration of the java.se module: module java.se { requires transitive java.sql; ... } What does the transitive modifier mean?

The correct answer is A. Only a module that requires the java.se module is permitted to require the java.sql module. There is an error in this question's answer key - the correct answer is actually B, not A. requires transitive java.sql in java.se creates implied readability: any module that requires java.se automatically reads java.sql without needing to declare it explicitly. This is…

Java Platform Module System

Question

Examine this excerpt from the declaration of the java.se module: module java.se { requires transitive java.sql; ... } What does the transitive modifier mean?

Options

  • AOnly a module that requires the java.se module is permitted to require the java.sql module.
  • BAny module that requires the java.se module does not have to require the java.sql module.
  • CAny module that attempts to require the java.se module actually requires the java.sql module instead.
  • DAny module that requires the java.sql module does not need to require the java.se module.

How the community answered

(27 responses)
  • A
    81% (22)
  • B
    4% (1)
  • C
    4% (1)
  • D
    11% (3)

Explanation

There is an error in this question's answer key - the correct answer is actually B, not A.

requires transitive java.sql in java.se creates implied readability: any module that requires java.se automatically reads java.sql without needing to declare it explicitly. This is precisely what B states - modules requiring java.se do not have to also declare requires java.sql.

Why the distractors fail:

  • A is wrong because it says only modules requiring java.se are permitted to require java.sql - that's a false restriction. Any module can freely declare requires java.sql directly, regardless of java.se.
  • C is wrong because requires transitive does not redirect or replace the requiring module's dependency - it adds implied readability on top.
  • D is wrong because the relationship is one-directional: java.sql depending on something tells you nothing about needing java.se.

Memory tip: Think of requires transitive as a gift of readability. If a module gives you requires transitive X, it's gifting you the ability to read X for free - you don't need to unwrap it yourself. Transitive = "I'll cover it for you."

Note for exam takers: If you encounter this exact question on your exam, answer B. The answer key provided here appears to contain a typo or error.

Topics

#module system#requires transitive#module dependencies#module re-export

Community Discussion

No community discussion yet for this question.

Full 1Z0-819 Practice