Java Development and Deployment Flashcards
5 cards from real 1Z0-811 practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 5 Java Development and Deployment flashcards as text
What is the purpose of the "module-info.java" file in a Java module?
Answer: To specify the modules that the current module depends on and the packages it exports
The `module-info.java` file is the module descriptor in the Java Platform Module System (JPMS). It explicitly defines a module's name, declares its dependencies on other modules using `requires`, and specifies which of its packages are accessible to other modules using `exports`. This file is crucial for enforcing strong encapsulation and reliable configuration in modular applications.
How does Java handle memory management and garbage collection?
Answer: By using a garbage collector to automatically reclaim memory from objects that are no longer in use
Java handles memory management automatically through a process called garbage collection. The garbage collector continuously monitors memory and reclaims space occupied by objects that are no longer referenced or reachable by the running application. This frees developers from manual memory allocation and deallocation, reducing memory leaks and improving application stability.
What does the "javac" command do?
Answer: It compiles Java source code into bytecode
The `javac` command is the Java compiler. Its primary function is to translate Java source code files (with a `.java` extension) into Java bytecode files (with a `.class` extension). These bytecode files are then executed by the Java Virtual Machine (JVM).
What is a JAR file in Java?
Answer: A compressed file format used to bundle multiple Java class files and associated metadata into a single archive
A JAR (Java Archive) file is a compressed file format, based on the ZIP format, used to bundle multiple Java class files, associated metadata, and resources (like images or configuration files) into a single archive. This makes it convenient for distributing and deploying Java applications and libraries as a single unit.
What is the -classpath option used for when running the java command?
Answer: To set the path for finding Java libraries and classes during runtime
When running the `java` command, the `-classpath` (or `-cp`) option is used to specify the path where the Java Virtual Machine (JVM) should look for user-defined classes and packages. This path includes directories containing `.class` files and JAR files, ensuring that the JVM can locate all necessary components for the application to execute correctly at runtime.