Page 1 of 1

About Question enthuware.ocpjp.v21.2.3144 :

Posted: Sun Apr 20, 2025 3:40 am
by n199a_
Question:

Consider the following code appearing in a module-info.java:

Code: Select all

java
module com.amazing.movies {
    requires transitive com.amazing.customer;
}
Identify the correct statements.

Options:

1. Any module that requires the com.amazing.movies module must also require the com.amazing.customer module.
2. Any module that requires the com.amazing.movies module can use the com.amazing.customer module without requiring it.
3. Only a module that requires the com.amazing.movies module can use the com.amazing.customer module.
4. Any module that requires the com.amazing.customer module must also require the com.amazing.movies module.
5. Any module that requires the com.amazing.movies module must require the com.amazing.customer module instead of com.amazing.movies.

---

Problem:

Options 2 and 3 effectively mean the same thing:

- Option 2 states that any module requiring `com.amazing.movies` can access `com.amazing.customer` without explicitly requiring it.
- Option 3 says that only modules requiring `com.amazing.movies` can access `com.amazing.customer`. That’s logically correct too — since transitive only works through the module that declares it.

So both statements are logically true, but the test allows you to pick only one.
That creates confusion because it seems like there are two valid answers — and there’s no clear reason why only one is accepted.

Re: About Question enthuware.ocpjp.v21.2.3144 :

Posted: Sun Apr 20, 2025 7:15 am
by admin
Option 3 is different from option 2 because option 3 means that a module that doesn't require the com.amazing.movies module cannot use classes from the com.amazing.customer module, but that is not true because such a module can have "requires com.amazing.cusomter" clause and then use the classes from the com.amazing.customer module. It is not necessary for such a module to have a "requires com.amazing.movies" module.