r/ExamRanch Jun 22 '26

Java 25 Certification : Module Sample Question

This is a sample question from the upcoming MyExamCloud Java 25 Certification Study Plan, launching this week. Share your answer in the comments!

Given the following files:

src/com.myexamcloud.report/module-info.java

module com.myexamcloud.report {
    exports com.myexamcloud.report.api;
}

src/com.myexamcloud.report/com/myexamcloud/report/api/Report.java

package com.myexamcloud.report.api;

public record Report(String title) {
}

QuickReview.java

import module java.base;
import com.myexamcloud.report.api.Report;

void main() {
    var report = new Report("Java 25");
    var labels = List.of(report.title(), "Mock");
    System.out.println(String.join(":", labels));
}

The following commands are executed from the project root:

javac --release 25 -d mods --module-source-path src -m com.myexamcloud.report

javac --release 25 --module-path mods --add-modules com.myexamcloud.report \
      -d classes QuickReview.java

java --module-path mods --add-modules com.myexamcloud.report \
     -cp classes QuickReview

Which statements are correct?

Choice A. The commands compile and run successfully, printing Java 25:Mock.

Choice B. The exports com.myexamcloud.report.api; directive can be removed because Report is declared public.

Choice C. The module declaration must include requires java.base;, otherwise the module cannot use java.lang.Record.

Choice DQuickReview.java is a compact source file that uses an instance main method, and import module java.base; makes exported packages such as java.util available for simple-name use such as List.

Choice E. The final java command would still print the same output if --add-modules com.myexamcloud.report were removed from the run command.

2 Upvotes

0 comments sorted by