QuizzesAdvanced Java Module System & Encapsulation in JDK 9+
advanced
java

Advanced Java Module System & Encapsulation in JDK 9+

Test your expertise in Java's module system and advanced encapsulation techniques introduced in JDK 9 and beyond.

20 minutes 10 questions Pass at 70%
Time Limit
20 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

10 questions on Advanced Java Module System & Encapsulation in JDK 9+. Work through them here, then start the quiz to answer them and see your score.

  1. 1.In the Java Module System, which directive is used to expose a package to other modules?

    • Aprovides
    • Bexports
    • Crequires
    • Dopens
  2. 2.What is the purpose of the 'requires transitive' directive in a module declaration?

    • ATo pass on module dependencies
    • BTo allow reflection
    • CTo make the module optional
    • DTo automatically export all packages
  3. 3.How does the 'opens' directive differ from 'exports' in a module-info.java file?

    • A'opens' exports all packages, 'exports' exports specific ones
    • B'opens' is deprecated, 'exports' is not
    • C'opens' is for compile-time access, 'exports' is for runtime reflection
    • D'opens' is for runtime reflection, 'exports' is for compile-time access
  4. 4.Which of the following is NOT a benefit of using the Java Module System?

    • AReduced memory usage
    • BFaster compilation
    • CBetter encapsulation
    • DImproved security
  5. 5.What is the effect of using 'provides ... with ...' in a module declaration?

    • AIt declares a service provider
    • BIt exports a package
    • CIt requires another module
    • DIt opens a package
  6. 6.Which of the following statements about unnamed modules is true?

    • AThey can only read exported packages of named modules
    • BThey are deprecated in JDK 11
    • CThey can read all named modules
    • DThey cannot read any named modules
  7. 7.In JDK 9+, what is the default access level for a package in a module if not explicitly exported?

    • APublic
    • BProtected
    • CModule-private
    • DPrivate
  8. 8.Which command-line option is used to specify a module path when running a Java application?

    • A--path
    • B--module
    • C--classpath
    • D--module-path
  9. 9.What is the primary purpose of the 'uses' directive in a module declaration?

    • ATo open a package
    • BTo export a package
    • CTo require another module
    • DTo declare a service dependency
  10. 10.Which of the following is a key feature of strong encapsulation in the Java Module System?

    • AOnly exported packages are accessible
    • BAll packages are accessible by default
    • CReflection is unrestricted
    • DAll classes are public by default