Explanation:Maven is based on the concept of a Project Object Model (POM). The POM contains information about the project and various configuration details used by Maven to build the project.
Incorrect! Try again.
2Which XML file is the core configuration file for a Maven project?
A.build.xml
B.maven.xml
C.pom.xml
D.config.xml
Correct Answer: pom.xml
Explanation:The pom.xml file is the core of a project's configuration in Maven. It is a single configuration file that contains the majority of information required to build a project.
Incorrect! Try again.
3In the standard Maven directory structure, where should the application source code be placed?
A.src/test/java
B.src/main/resources
C.src/main/java
D.target/classes
Correct Answer: src/main/java
Explanation:According to the Maven Standard Directory Layout, application source code goes in src/main/java.
Incorrect! Try again.
4What is the primary purpose of the Maven Build Lifecycle?
A.To download dependencies only
B.To define a clearly defined process for building and distributing a particular artifact
C.To write Java code automatically
D.To configure the IDE settings
Correct Answer: To define a clearly defined process for building and distributing a particular artifact
Explanation:The build lifecycle is a well-defined sequence of phases (like validate, compile, test, package, etc.) that defines the process for building and distributing artifacts.
Incorrect! Try again.
5Which of the following is NOT a built-in Maven build lifecycle?
A.default
B.clean
C.site
D.debug
Correct Answer: debug
Explanation:Maven has three built-in build lifecycles: default (handles project deployment), clean (handles project cleaning), and site (handles the creation of the project's site documentation). 'debug' is not a lifecycle.
Incorrect! Try again.
6What does the clean lifecycle do?
A.Compiles the source code
B.Runs unit tests
C.Removes all files generated by the previous build
D.Deploys the artifact to a remote repository
Correct Answer: Removes all files generated by the previous build
Explanation:The clean lifecycle consists of the pre-clean, clean, and post-clean phases. Its primary goal is to remove the target directory and all files generated by previous builds.
Incorrect! Try again.
7Which Maven phase is responsible for compiling the source code of the project?
A.validate
B.compile
C.test
D.package
Correct Answer: compile
Explanation:The compile phase compiles the source code of the project.
Incorrect! Try again.
8In the Maven coordinate system (GAV), what does GroupId represent?
A.The specific version of the project
B.A unique identifier for the project's organization or group
C.The name of the artifact (project)
D.The type of packaging (e.g., jar, war)
Correct Answer: A unique identifier for the project's organization or group
Explanation:GroupId identifies the project's group uniquely across all projects, often resembling a reversed domain name (e.g., com.example.myproject).
Incorrect! Try again.
9Where are Maven dependencies stored locally on a developer's machine?
A.In the bin folder of the Maven installation
B.In the target folder of the project
C.In the Local Repository (usually ~/.m2/repository)
D.In the System32 folder
Correct Answer: In the Local Repository (usually ~/.m2/repository)
Explanation:Maven downloads dependencies to the local repository, typically located at ~/.m2/repository (User Home/.m2/repository), to avoid downloading them repeatedly.
Incorrect! Try again.
10Which dependency scope indicates that the dependency is needed for compiling and running the application, and is the default scope?
A.test
B.provided
C.compile
D.runtime
Correct Answer: compile
Explanation:compile is the default scope. Dependencies with this scope are available in all classpaths (compile, test, run) and are propagated to dependent projects.
Incorrect! Try again.
11What is the purpose of the test dependency scope?
A.The dependency is required for normal use of the application
B.The dependency is provided by the JDK or a container
C.The dependency is not required for compilation but is for execution
D.The dependency is only required for compiling and running tests
Correct Answer: The dependency is only required for compiling and running tests
Explanation:test scope indicates the dependency is not required for normal use of the application, only for the test compilation and execution phases (e.g., JUnit).
Incorrect! Try again.
12Which command is used to install the project artifact (e.g., jar) into the local repository?
A.mvn compile
B.mvn package
C.mvn install
D.mvn deploy
Correct Answer: mvn install
Explanation:The install phase installs the package into the local repository, for use as a dependency in other projects locally.
Incorrect! Try again.
13What is a Maven Plugin?
A.A library that must be included in the final WAR file
B.A collection of one or more goals that perform specific tasks during the build
C.A configuration file for database connections
D.A type of dependency scope
Correct Answer: A collection of one or more goals that perform specific tasks during the build
Explanation:Maven is plugin-based. A plugin is a collection of goals (tasks). For example, the maven-compiler-plugin has goals to compile code.
Incorrect! Try again.
14Which directory contains the compiled bytecode (.class files) after a build?
A.src/main/java
B.src/bin
C.target/classes
D.dist
Correct Answer: target/classes
Explanation:The target directory is the default output folder. Compiled production classes are placed in target/classes.
Incorrect! Try again.
15What defines a specific task that a plugin can perform?
A.Phase
B.Goal
C.Cycle
D.Scope
Correct Answer: Goal
Explanation:A Goal represents a specific task (finer-grained than a build phase) that contributes to the building and managing of a project.
Incorrect! Try again.
16If you want to skip running unit tests during a build, which flag should you use?
A.-DnoTest
B.-DskipTests
C.-Dmaven.test.skip=false
D.--ignore-tests
Correct Answer: -DskipTests
Explanation:Passing -DskipTests to the maven command compiles the tests but skips their execution. -Dmaven.test.skip=true skips both compilation and execution.
Incorrect! Try again.
17Which element in the pom.xml allows you to manage versions of dependencies for child projects without explicitly defining them in the child?
A.<dependencies>
B.<dependencyManagement>
C.<plugins>
D.<properties>
Correct Answer: <dependencyManagement>
Explanation:dependencyManagement allows parent POMs to define dependencies and their versions. Child POMs can then reference these dependencies without specifying the version.
Incorrect! Try again.
18What is the Maven Central Repository?
A.A repository located on your local hard drive
B.A repository managed by your company
C.A public, community-managed repository where Maven downloads dependencies from by default
D.A repository that only contains snapshot versions
Correct Answer: A public, community-managed repository where Maven downloads dependencies from by default
Explanation:Maven Central is the default remote repository provided by the Maven community, containing a vast library of open-source artifacts.
Incorrect! Try again.
19Which packaging type is the default if the <packaging> tag is omitted in the pom.xml?
A.war
B.ear
C.pom
D.jar
Correct Answer: jar
Explanation:If the packaging element is not specified, it defaults to jar (Java ARchive).
Incorrect! Try again.
20What is the order of execution for the default lifecycle phases?
Explanation:The standard order is: validate (check project is correct), compile (source), test (unit tests), package (create JAR/WAR), install (to local repo), deploy (to remote repo).
Incorrect! Try again.
21What is a SNAPSHOT version in Maven?
A.A stable release version
B.A version that is final and immutable
C.A development version that is subject to change
D.A version that has been deprecated
Correct Answer: A development version that is subject to change
Explanation:The suffix -SNAPSHOT indicates a version under development. Maven checks for updates to snapshot dependencies more frequently than release versions.
Incorrect! Try again.
22Which command creates a new Maven project structure using a template?
A.mvn new
B.mvn create
C.mvn archetype:generate
D.mvn init
Correct Answer: mvn archetype:generate
Explanation:The archetype:generate goal is used to generate a new project from an archetype (a project template).
Incorrect! Try again.
23In the pom.xml, what is the <properties> section typically used for?
A.Defining the project name
B.Defining reusable variables like version numbers or encoding settings
C.Listing the developers
D.Configuring the build output directory
Correct Answer: Defining reusable variables like version numbers or encoding settings
Explanation:The properties section is used to define placeholders (variables) that can be reused throughout the POM, such as <spring.version>5.3.10</spring.version>.
Incorrect! Try again.
24What does the provided dependency scope imply?
A.The dependency is needed for compiling and testing, but will be provided by the runtime environment (e.g., Servlet API)
B.The dependency is needed only for unit tests
C.The dependency is always included in the final packaged artifact
D.The dependency is strictly for the site lifecycle
Correct Answer: The dependency is needed for compiling and testing, but will be provided by the runtime environment (e.g., Servlet API)
Explanation:provided scope means the dependency is required to build the application, but it should not be included in the output (e.g., WAR) because the web server (like Tomcat) provides it.
Incorrect! Try again.
25Which phase comes immediately before package in the default lifecycle?
A.compile
B.test
C.install
D.validate
Correct Answer: test
Explanation:The sequence includes ... compile -> test -> package ...
Incorrect! Try again.
26Where should non-Java resources (like application.properties or XML config) be placed in a standard Maven project?
A.src/main/java
B.src/main/config
C.src/main/resources
D.src/resources
Correct Answer: src/main/resources
Explanation:Resources that should be available on the classpath (and packaged into the JAR/WAR) go in src/main/resources.
Incorrect! Try again.
27What is a Transitive Dependency?
A.A dependency that is manually copied into the project
B.A dependency of a dependency that Maven automatically includes
C.A dependency that is only used for testing
D.A dependency that is excluded from the build
Correct Answer: A dependency of a dependency that Maven automatically includes
Explanation:If Project A depends on B, and B depends on C, Maven automatically pulls in C for Project A. C is a transitive dependency.
Incorrect! Try again.
28How can you exclude a specific transitive dependency in the pom.xml?
A.Using the <exclusions> tag within the dependency declaration
B.Using the <remove> tag
C.Deleting the jar from the local repository
D.Using the <ignore> tag
Correct Answer: Using the <exclusions> tag within the dependency declaration
Explanation:You can use the <exclusions> element inside a specific <dependency> to prevent specific transitive dependencies from being included.
Incorrect! Try again.
29What is the Super POM?
A.The largest POM file in the project
B.A POM file that inherits from all other POMs
C.The default parent POM that all Maven projects inherit from implicitly
D.A plugin for managing large projects
Correct Answer: The default parent POM that all Maven projects inherit from implicitly
Explanation:All Maven POMs inherit from a base Super POM which defines defaults for repositories, plugin versions, and directory structure.
Incorrect! Try again.
30Which Maven plugin is primarily responsible for running unit tests?
A.maven-compiler-plugin
B.maven-jar-plugin
C.maven-surefire-plugin
D.maven-deploy-plugin
Correct Answer: maven-surefire-plugin
Explanation:The Maven Surefire Plugin is the default plugin used during the test phase to execute unit tests.
Incorrect! Try again.
31Which Maven command is used to generate a project documentation site?
A.mvn doc
B.mvn site
C.mvn documentation
D.mvn report
Correct Answer: mvn site
Explanation:The mvn site command triggers the site lifecycle to generate documentation for the project.
Incorrect! Try again.
32What does the validate phase do?
A.Compiles the code
B.Validates that the project is correct and all necessary information is available
C.Checks if the tests pass
D.Validates the XML syntax of the pom.xml only
Correct Answer: Validates that the project is correct and all necessary information is available
Explanation:validate is the first phase of the default lifecycle. It ensures the project structure is correct and dependencies can be resolved.
Incorrect! Try again.
33In a multi-module project, what packaging type must the Parent POM have?
A.jar
B.war
C.pom
D.bundle
Correct Answer: pom
Explanation:A parent or aggregator project (one that contains modules) must have <packaging>pom</packaging>.
Incorrect! Try again.
34Which command would you use to run a Maven build in offline mode?
A.mvn -o package
B.mvn --offline package
C.mvn -offline package
D.mvn -no-net package
Correct Answer: mvn -o package
Explanation:The -o (or --offline) flag tells Maven not to try to connect to remote repositories.
Incorrect! Try again.
35What is the purpose of the deploy phase?
A.To copy the final package to the remote repository for sharing with other developers and projects
B.To copy the final package to the local repository
C.To run the application on a local server
D.To generate the source code
Correct Answer: To copy the final package to the remote repository for sharing with other developers and projects
Explanation:deploy is the final phase of the default lifecycle, uploading the artifact to a remote repository (like Nexus or Artifactory).
Incorrect! Try again.
36The <modules> tag in a pom.xml is used for:
A.Defining external libraries
B.Listing sub-projects (aggregating) in a multi-module build
C.Configuring Java modules (Jigsaw)
D.Defining plugin configurations
Correct Answer: Listing sub-projects (aggregating) in a multi-module build
Explanation:The <modules> section lists the sub-directories (sub-projects) that should be included in the build of an aggregator project.
Incorrect! Try again.
37What is the Effective POM?
A.A POM that has no errors
B.The result of merging the project's POM with its parent POMs and the Super POM
C.A plugin that optimizes the POM
D.The POM file located in the target directory
Correct Answer: The result of merging the project's POM with its parent POMs and the Super POM
Explanation:The Effective POM represents the final configuration Maven uses, derived from the project POM, hierarchy of parent POMs, and the Super POM.
Incorrect! Try again.
38Which directory holds the source code for unit tests?
A.src/main/test
B.src/test/java
C.src/tests
D.test/java
Correct Answer: src/test/java
Explanation:Standard Maven layout places test source code in src/test/java.
Incorrect! Try again.
39If a dependency is defined in <dependencies>, what happens if the version is missing?
A.Maven downloads the latest version
B.Maven downloads the release version
C.The build fails, unless the version is managed in <dependencyManagement> of a parent
D.Maven asks the user for the version
Correct Answer: The build fails, unless the version is managed in <dependencyManagement> of a parent
Explanation:A version is mandatory for dependencies. It can only be omitted if it is defined in the <dependencyManagement> section of a parent POM.
Incorrect! Try again.
40What is the Maven command to remove the target directory?
A.mvn delete
B.mvn remove
C.mvn clean
D.mvn erase
Correct Answer: mvn clean
Explanation:The mvn clean command invokes the clean lifecycle, which deletes the build directory (target).
Incorrect! Try again.
41Which plugin is used to compile Java sources?
A.maven-source-plugin
B.maven-javac-plugin
C.maven-compiler-plugin
D.maven-build-plugin
Correct Answer: maven-compiler-plugin
Explanation:The maven-compiler-plugin is responsible for compiling the Java source files.
Incorrect! Try again.
42How do you specify the Java version for compilation in the pom.xml?
A.Using <java.version> tag in dependencies
B.Using maven.compiler.source and maven.compiler.target properties
C.It is automatically detected from the OS
D.Using the <jdk> tag
Correct Answer: Using maven.compiler.source and maven.compiler.target properties
Explanation:You typically set the Java version using properties like <maven.compiler.source>1.8</maven.compiler.source> and <maven.compiler.target>1.8</maven.compiler.target>.
Incorrect! Try again.
43What is the result of mvn package for a project with <packaging>war</packaging>?
A.A JAR file
B.A WAR file in the target directory
C.A ZIP file
D.An EAR file
Correct Answer: A WAR file in the target directory
Explanation:The package phase creates the artifact format specified in the packaging tag. If it is war, it generates a Web Application Archive.
Incorrect! Try again.
44Which of the following describes the Dependency Mediation rule: 'Nearest Definition'?
A.Maven uses the version of the dependency declared deepest in the dependency tree
B.Maven uses the newest version available
C.Maven uses the version of the dependency closest to your project in the dependency tree
D.Maven errors out if duplicate dependencies are found
Correct Answer: Maven uses the version of the dependency closest to your project in the dependency tree
Explanation:If two versions of the same artifact are in the dependency tree, Maven picks the one 'nearest' to the project (fewest hops). If depths are equal, the first one declared wins.
Incorrect! Try again.
45What is the purpose of the settings.xml file in Maven?
A.To define project dependencies
B.To configure Maven installation settings, such as proxy servers and local repository location
C.To configure the compiler version
D.To write unit tests
Correct Answer: To configure Maven installation settings, such as proxy servers and local repository location
Explanation:settings.xml (usually in ~/.m2/) contains user-specific configuration like proxy settings, mirrors, and authentication for remote repositories.
Incorrect! Try again.
46Which scope should be used for a JDBC driver implementation needed only at runtime?
A.compile
B.provided
C.runtime
D.test
Correct Answer: runtime
Explanation:runtime scope indicates that the dependency is not required for compilation, but is for execution (e.g., JDBC drivers).
Incorrect! Try again.
47What is the syntax to execute a specific goal from a plugin directly?
A.mvn plugin-goal
B.mvn plugin:goal
C.mvn plugin::goal
D.mvn -run plugin goal
Correct Answer: mvn plugin:goal
Explanation:The syntax is mvn [plugin-name]:[goal-name]. Example: mvn dependency:tree.
Incorrect! Try again.
48Which command displays the dependency tree of the project?
A.mvn dependency:tree
B.mvn show:dependencies
C.mvn tree:list
D.mvn list:dependency
Correct Answer: mvn dependency:tree
Explanation:The dependency:tree goal allows you to visualize the dependency hierarchy and transitive dependencies.
Incorrect! Try again.
49In the pom.xml, the <modelVersion> element usually contains which value?
A.1.0.0
B.3.0.0
C.4.0.0
D.5.0.0
Correct Answer: 4.0.0
Explanation:4.0.0 is the current version of the Project Object Model supported by Maven 2 and 3.
Incorrect! Try again.
50Where does Maven look for the settings.xml file by default?
A.Inside the project folder
B.In the .m2 directory of the user's home directory
C.In the Windows Registry
D.In the Java installation folder
Correct Answer: In the .m2 directory of the user's home directory
Explanation:The user-specific settings are located at ${user.home}/.m2/settings.xml.
Incorrect! Try again.
Give Feedback
Help us improve by sharing your thoughts or reporting issues.