Modules in Java

Looking to get certified as a Java SE Developer with Oracle?

Check out this highly rated Udemy course by the Skilltoz team with excellent practice questions that will help you prepare for the Java Certification exam.

For sample Questions, you can also refer to

Modules were introduced in Java from version 9.

What is a module declaration?

A module declaration begins with the keyword module, followed by a module name and a module body enclosed in braces.

module modulename {

A module declaration is defined in a file named It is placed in the module’s root folder.

What is a module descriptor?

The file that we get when we compile the file is the module descriptor. It contains the metadata that specifies the module’s dependencies.

What are some of the advantages of modules?

  • Startup time is less
  • Memory requirement is low
  • It is possible to prevent access of packages by other packages outside the module
  • It is possible to omit certain parts of JDK from a custom build

Practice Questions

Q1. Is this a valid module-info file?

public module com.skilltoz {
exports com.skilltoz;

No, the modifer public should not be used for a module-info file. So this will not compile.

Q2. Where should the module-info file be placed for the module com.skilltoz declared in this module-info file?

module com.skilltoz {
exports com.skilltoz;

A. com folder
B. skilltoz folder
C. None of these

C is correct. It would need to be placed at the root directory of the module, which would be at the same level as the com folder.


To learn more about Java 9 Modules, visit this link.

Leave a Reply

Your email address will not be published. Required fields are marked *