Assume you have an application with the main class ๐๐๐๐๐.๐ด๐๐๐.
This application is packaged in a JAR file named ๐๐๐๐๐.๐๐๐ and depends on a JAR called ๐๐๐.๐๐๐, which uses types in ๐๐๐.๐๐๐.
The ๐๐๐.๐๐๐ has just been modularized into a module named ๐๐๐.
You decide to turn your JAR file into a module with name ๐๐๐๐๐.
๐โโ๏ธ Given both module declarations are valid, which two of the following are the correct commands to execute your application?
* ๐๐๐๐ -๐๐ ๐๐๐.๐๐๐;๐๐๐.๐๐๐;๐๐๐๐๐.๐๐๐ ๐๐๐๐๐.๐ด๐๐๐
* ๐๐๐๐ -๐๐ ๐๐๐.๐๐๐;๐๐๐.๐๐๐;๐๐๐๐๐.๐๐๐ -๐ ๐๐๐๐๐/๐๐๐๐๐.๐ด๐๐๐
* ๐๐๐๐ -๐๐ ๐๐๐.๐๐๐;๐๐๐.๐๐๐ -๐ ๐๐๐๐๐.๐๐๐ -๐ ๐๐๐๐๐/๐๐๐๐๐.๐ด๐๐๐
* ๐๐๐๐ -๐๐ ๐๐๐.๐๐๐ -๐ ๐๐๐.๐๐๐;๐๐๐๐๐.๐๐๐ -๐ ๐๐๐๐๐/๐๐๐๐๐.๐ด๐๐๐
* ๐๐๐๐ -๐ ๐๐๐.๐๐๐;๐๐๐.๐๐๐;๐๐๐๐๐.๐๐๐ -๐ ๐๐๐๐๐/๐๐๐๐๐.๐ด๐๐๐
๐กAnswer:
* ๐๐๐๐ -๐๐ ๐๐๐.๐๐๐;๐๐๐.๐๐๐;๐๐๐๐๐.๐๐๐ ๐๐๐๐๐.๐ด๐๐๐
* ๐๐๐๐ -๐ ๐๐๐.๐๐๐;๐๐๐.๐๐๐;๐๐๐๐๐.๐๐๐ -๐ ๐๐๐๐๐/๐๐๐๐๐.๐ด๐๐๐
๐ฉโ๐ซ Explanation:
When ๐๐๐๐๐.๐๐๐ is placed on the module path, neither ๐๐๐.๐๐๐ nor ๐๐๐.๐๐๐ can be on the classpath.
The reason is that a named module cannot read packages in the unnamed module.
This means options
๐๐๐๐ -๐๐ ๐๐๐.๐๐๐;๐๐๐.๐๐๐ -๐ ๐๐๐๐๐.๐๐๐ -๐ ๐๐๐๐๐/๐๐๐๐๐.๐ด๐๐๐ and
๐๐๐๐ -๐๐ ๐๐๐.๐๐๐ -๐ ๐๐๐.๐๐๐;๐๐๐๐๐.๐๐๐ -๐ ๐๐๐๐๐/๐๐๐๐๐.๐ด๐๐๐ are wrong.
Then ๐๐๐๐ -๐๐ ๐๐๐.๐๐๐;๐๐๐.๐๐๐;๐๐๐๐๐.๐๐๐ -๐ ๐๐๐๐๐/๐๐๐๐๐.๐ด๐๐๐ is incorrect because when ๐๐๐๐๐.๐๐๐ is on the classpath ,it's considered part of the unnamed module.
This means there would be no module named ๐๐๐๐๐.
๐๐๐๐ -๐๐ ๐๐๐.๐๐๐;๐๐๐.๐๐๐;๐๐๐๐๐.๐๐๐ ๐๐๐๐๐.๐ด๐๐๐ is correct since both modular JARs will be considered regular JARs, and the application will run as if it was on a non-modular system.
๐๐๐๐ -๐ ๐๐๐.๐๐๐;๐๐๐.๐๐๐;๐๐๐๐๐.๐๐๐ -๐ ๐๐๐๐๐/๐๐๐๐๐.๐ด๐๐๐ is correct too, as ๐๐๐.๐๐๐ becomes an automatic module when placed on the module path. An automatic module exports all of its packages, hence, can be used by foo.jar.
#java #certificationquestion #ocp
๐๐