About Question enthuware.ocpjp.ii.v11.2.3447 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
sir_Anduin@yahoo.de
Posts: 62
Joined: Fri Aug 07, 2015 2:16 pm
Contact:

About Question enthuware.ocpjp.ii.v11.2.3447 :

Post by sir_Anduin@yahoo.de »

I dont understand why 1 is incorrect
The module that defines Print service must be present on --module-source-path for book module to compile.
If I require it, it should be on the module-path

admin
Site Admin
Posts: 10389
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.ii.v11.2.3447 :

Post by admin »

It is explained in the explanation:
book module can be compiled in two ways:  Either put the code for the org.pdf module on the --module-source-path  or put compiled classes/jar of the org.pdf module on the --module-path.
That is why option 1 is incorrect. It says "must". But as explained above, to compile the book module, the module containing the print service can be put on the the --module-path as well.

wakedeer
Posts: 3
Joined: Tue Apr 21, 2020 7:04 am
Contact:

Re: About Question enthuware.ocpjp.ii.v11.2.3447 :

Post by wakedeer »

What does The module that defines Print service mean?
Is it org.pdf module or a service provider module?

admin
Site Admin
Posts: 10389
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.ii.v11.2.3447 :

Post by admin »

The module that defines the print service is the module that defines the interfaces of that service i.e. org.pdf.
The service, in this case, is defined by org.pdf.Print interface, which is why the module-info has uses org.pdf.Print; clause.

The module that implements the print service could be in any other module but there will be no direct dependency on that module in the book module.

For thorough understanding, you may want to go through this document: http://openjdk.java.net/projects/jigsaw/spec/sotms/

liugengyu
Posts: 8
Joined: Thu Jul 09, 2020 4:09 pm
Contact:

Re: About Question enthuware.ocpjp.ii.v11.2.3447 :

Post by liugengyu »

I don't understand why the option "The module that defines Print service must be present on --module-path for book module to execute." is incorrect.

admin
Site Admin
Posts: 10389
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.ii.v11.2.3447 :

Post by admin »

Because it is not a must. As explained in the explanation, it can work even if you have the source code of the module that defines print service on --module-source-path.

Deleted User 6318

Re: About Question enthuware.ocpjp.ii.v11.2.3447 :

Post by Deleted User 6318 »

At least one module that provides Print service must be present on --module-path for book module to execute.
Why is that not necessarily true? Because there must be exactly one, not more?

admin
Site Admin
Posts: 10389
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.ii.v11.2.3447 :

Post by admin »

A service implementation is not actually required for execution of a module because services are loaded only when required.

For example, if the service user module has this code:

Code: Select all

java.util.ServiceLoader<BloggerService> bsLoader = java.util.ServiceLoader.load(BloggerService.class);///
for (BloggerService bs : bsLoader){
     bs.blog("Hello from textbook");
}

//or

Optional<BloggerService> bs1 = bsLoader.findFirst();
bs1.ifPresent(bs->bs.method());
There will be no error while execution.

But if a module says it uses a particular service, then it would be fair to assume that it would actually try to access that service. If there is no module in the module path that provides the service, then it really depends on how the application is coded. So, I agree that this option seems too vague.

-Paul.

kabanvau
Posts: 14
Joined: Thu Nov 21, 2019 5:48 am
Contact:

Re: About Question enthuware.ocpjp.ii.v11.2.3447 :

Post by kabanvau »

You say:

The module that defines the print service is the module that defines the interfaces of that service i.e. org.pdf.

And this option was marked as correct:

A module that defines Print service may be added later without requiring book module to recompile.

How can you add an interface definition later without requiring book module to recompile? You can do it with a service provider only, which implements that interface, isn't it?

admin
Site Admin
Posts: 10389
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.ii.v11.2.3447 :

Post by admin »

Yes, as noted in the explanations, the wording is ambiguous.
Logically, the module that defines the service (i.e. the module that contains the interface) must be available at compile time. One or more modules that implement the service need to be present only during the execution.

You need to select the best options. Depending on the number of options that you have to select, you might have trouble selecting an option due to unclear wording.
This question is just meant to make you aware of this issue with module related questions.

pavel.gurinovich
Posts: 11
Joined: Mon Nov 18, 2019 4:59 am
Contact:

Re: About Question enthuware.ocpjp.ii.v11.2.3447 :

Post by pavel.gurinovich »

A module that defines Print service may be added later without requiring book module to recompile.
May be in this answer word implements was mistakenly replaced by defines?

admin
Site Admin
Posts: 10389
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.ii.v11.2.3447 :

Post by admin »

Yes, that is possible. But we are not sure. Just be aware of the issue and answer such question carefully during the real exam.

Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests