QuizzesJava Module System: Intermediate Concepts and Applications
intermediate
java

Java Module System: Intermediate Concepts and Applications

Test your understanding of Java's Module System with intermediate-level questions.

18 minutes 12 questions Pass at 70%
Time Limit
18 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

12 questions on Java Module System: Intermediate Concepts and Applications. Work through them here, then start the quiz to answer them and see your score.

  1. 1.What is the primary purpose of the Java Module System introduced in Java 9?

    • ATo improve the performance of Java applications
    • BTo encapsulate packages and manage dependencies
    • CTo provide a new syntax for lambda expressions
    • DTo replace the Java Virtual Machine
  2. 2.Which of the following is a valid module declaration in a module-info.java file?

    • Amodule-info { exports com.example; }
    • Bpackage com.example { exports com.example; }
    • Cexports com.example { module com.example; }
    • Dmodule com.example { exports com.example; }
  3. 3.How does the Java Module System handle split packages?

    • AIt merges split packages automatically
    • BIt ignores split packages
    • CIt prevents split packages across modules
    • DIt allows split packages by default
  4. 4.Which command is used to compile a module in Java?

    • Ajavac --module-path <path> <source-files>
    • Bjavap -module <module-name>
    • Cjava -module <module-name>
    • Djavac -d <output-dir> <source-files>
  5. 5.What keyword is used to specify a module dependency in Java?

    • Auses
    • Bimports
    • Crequires
    • Ddepends
  6. 6.What is the function of the 'exports' directive in a module declaration?

    • ATo make a module dependent on another module
    • BTo define the main class of the module
    • CTo import packages from another module
    • DTo make a module's packages accessible to other modules
  7. 7.How can a module specify that it uses a service provided by another module?

    • Aprovides
    • Brequires
    • Cexports
    • Duses
  8. 8.Which of the following is true about unnamed modules?

    • AThey are explicitly declared in module-info.java
    • BThey are not allowed in Java 9 and above
    • CThey contain all JARs on the classpath
    • DThey can access all named modules
  9. 9.What is the purpose of the 'provides ... with ...' directive in a module declaration?

    • ATo import a package from another module
    • BTo declare a module's dependencies
    • CTo specify the service implementation a module provides
    • DTo export a package to another module
  10. 10.Which tool is used to create a custom runtime image containing specific modules?

    • Ajava
    • Bjmod
    • Cjlink
    • Djavac
  11. 11.What happens if a module does not explicitly export any packages?

    • AIt automatically exports all packages to unnamed modules
    • BAll of its packages are exported by default
    • CIt cannot be compiled
    • DNone of its packages are accessible to other modules
  12. 12.In the context of the Java Module System, what is a 'transitive' dependency?

    • AA dependency that is required by another module
    • BA dependency that is automatically exported to modules requiring the current module
    • CA dependency that is only used during testing
    • DA dependency that is optional