1Z0-830 practice question 8 of 25
When compiling unnamed modules, which directory structure is recommended for source files?
Full set: 116 questionsThe standard and recommended convention for organizing Java source files, which applies to code compiled for both named and unnamed modules, is to mirror the package structure in the file system. A root source directory (e.g., src) contains a hierarchy of subdirectories corresponding to the package names. For example, a class com.example.MyClass should be in the file src/com/example/MyClass.java. This structure allows the compiler and build tools to locate source files predictably.
A. Placing all source files in one directory is not scalable and leads to name collisions for classes in different packages.
C. Placing each source file in its own directory is unnecessarily complex and violates the standard package-to-directory mapping convention.
D. While the compiler can be passed an explicit list of files, a consistent structure is required for any maintainable project and is expected by all standard Java tools.
1. Oracle Corporation. (2023). The Java™ Tutorials: Creating and Using Packages. In the "Essential Java Classes" trail, "Packages" lesson. "The package name and the directory structure must match."
2. Oracle Corporation. (2023). javac - Java programming language compiler. In Java Development Kit 21 Tool Specifications. The documentation for -sourcepath and -d options implicitly relies on this package-based directory structure to locate and place files.
3. Stroustrup, B. (2014). Programming: Principles and Practice Using C++ (2nd ed.). Addison-Wesley. (While for C++, the principle of mapping namespaces/packages to directory structures for project organization is a widely accepted software engineering practice, also taught in university courses like MIT's 6.005).
Keep practicing
Take the free 1Z0-830 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other 1Z0-830 practice questions
- Question 1A consumer needs to access a service provided by another module. Which of the following s…
- Question 2Which of the following statements is TRUE about modules in Java SE 21?
- Question 3What interface does a class need to implement to be eligible for serialization?
- Question 4What is the primary benefit of encapsulation in Java?
- Question 5A Path object represents which of the following?
- Question 6Which of the following statements about overloaded methods with varargs is TRUE?
