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…
Question
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)- A81% (22)
- B4% (1)
- C4% (1)
- D11% (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.seare permitted to requirejava.sql- that's a false restriction. Any module can freely declarerequires java.sqldirectly, regardless ofjava.se. - C is wrong because
requires transitivedoes 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.sqldepending on something tells you nothing about needingjava.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
Community Discussion
No community discussion yet for this question.