Chapter 1. Understanding Modules

1.1.  Describe the Modular JDK

Question 010101

Given the code fragment:

try (
    Connection conn = DriverManager.getConnection(...);
    Statement stmt = conn.createStatement();) {
    // ...
}
					
					

Which two actions when done simultaneously will allow the code compile successfully?

Options (choose 2):

  1. Add to the class definition: import java.sql.*;

  2. Add to the class definition: requires java.sql.*;

  3. Add to the module definition: requires java.base;

  4. Add to the module definition: requires java.se;

  5. Add to the module definition: open java.sql;

Question 010102

You are writing a modular application for Java 11 platform which uses SAX XML parser.

From JavaDoc you know that the javax.xml.parsers.SAXParser parser class belongs to java.xml module.

Which step you must do in order to use this class in your application?

Options (choose 1):

  1. Add the option to java and javac: -p java.xml

  2. Add the option to java and javac: -cp java.xml.mod

  3. Add directive to the module definition: requires java.xml;

  4. Add directive to the module definition: requires java.base;

Question 010103

While compiling your modular application you got the error from javac:

import java.sql.Connection;
           ^
  (package java.sql is declared in module java.sql, but module modS does not read it)
1 error					
					

Which two changes when done independently will resolve this error?

Options (choose 2):

  1. Run javac with option: --module-path java.sql

  2. Run javac with option: -modulepath java.sql

  3. Run javac with option: -mp java.sql

  4. Add directive to the module definition: requires java.sql;

  5. Add directive to the module definition: requires transitive java.sql;

Professional hosting         Exam 1Z0-817: Upgrade OCP Java 6, 7 & 8 to Java SE 11 Developer Study Guide     Exam 1Z0-810: Upgrade to Java SE 8 Programmer Quiz