Unit 6: Working with Maven - Practice Quiz

INT331 — Fundamentals Of Devops 50 Questions
0 Correct 0 Wrong 50 Left
0/50

1 What is the fundamental unit of work in Maven?

A. The Ant Task
B. The Gradle File
C. The Project Object Model (POM)
D. The Build Script

2 Which XML file is the core configuration file for a Maven project?

A. pom.xml
B. maven.xml
C. config.xml
D. build.xml

3 In the standard Maven directory structure, where should the application source code be placed?

A. src/main/resources
B. target/classes
C. src/test/java
D. src/main/java

4 What is the primary purpose of the Maven Build Lifecycle?

A. To define a clearly defined process for building and distributing a particular artifact
B. To download dependencies only
C. To configure the IDE settings
D. To write Java code automatically

5 Which of the following is NOT a built-in Maven build lifecycle?

A. clean
B. default
C. site
D. debug

6 What does the clean lifecycle do?

A. Deploys the artifact to a remote repository
B. Runs unit tests
C. Compiles the source code
D. Removes all files generated by the previous build

7 Which Maven phase is responsible for compiling the source code of the project?

A. compile
B. test
C. package
D. validate

8 In the Maven coordinate system (GAV), what does GroupId represent?

A. A unique identifier for the project's organization or group
B. The name of the artifact (project)
C. The specific version of the project
D. The type of packaging (e.g., jar, war)

9 Where are Maven dependencies stored locally on a developer's machine?

A. In the System32 folder
B. In the target folder of the project
C. In the Local Repository (usually ~/.m2/repository)
D. In the bin folder of the Maven installation

10 Which dependency scope indicates that the dependency is needed for compiling and running the application, and is the default scope?

A. runtime
B. test
C. compile
D. provided

11 What is the purpose of the test dependency scope?

A. The dependency is provided by the JDK or a container
B. The dependency is only required for compiling and running tests
C. The dependency is not required for compilation but is for execution
D. The dependency is required for normal use of the application

12 Which command is used to install the project artifact (e.g., jar) into the local repository?

A. mvn deploy
B. mvn compile
C. mvn install
D. mvn package

13 What is a Maven Plugin?

A. A collection of one or more goals that perform specific tasks during the build
B. A configuration file for database connections
C. A type of dependency scope
D. A library that must be included in the final WAR file

14 Which directory contains the compiled bytecode (.class files) after a build?

A. dist
B. src/bin
C. src/main/java
D. target/classes

15 What defines a specific task that a plugin can perform?

A. Phase
B. Scope
C. Cycle
D. Goal

16 If you want to skip running unit tests during a build, which flag should you use?

A. -Dmaven.test.skip=false
B. -DnoTest
C. --ignore-tests
D. -DskipTests

17 Which element in the pom.xml allows you to manage versions of dependencies for child projects without explicitly defining them in the child?

A. <dependencyManagement>
B. <dependencies>
C. <plugins>
D. <properties>

18 What is the Maven Central Repository?

A. A repository that only contains snapshot versions
B. A public, community-managed repository where Maven downloads dependencies from by default
C. A repository managed by your company
D. A repository located on your local hard drive

19 Which packaging type is the default if the <packaging> tag is omitted in the pom.xml?

A. ear
B. pom
C. war
D. jar

20 What is the order of execution for the default lifecycle phases?

A. validate, compile, test, package, install, deploy
B. compile, validate, package, test, install, deploy
C. test, compile, validate, install, package, deploy
D. validate, test, compile, install, package, deploy

21 What is a SNAPSHOT version in Maven?

A. A development version that is subject to change
B. A version that is final and immutable
C. A version that has been deprecated
D. A stable release version

22 Which command creates a new Maven project structure using a template?

A. mvn new
B. mvn create
C. mvn init
D. mvn archetype:generate

23 In the pom.xml, what is the <properties> section typically used for?

A. Listing the developers
B. Configuring the build output directory
C. Defining the project name
D. Defining reusable variables like version numbers or encoding settings

24 What does the provided dependency scope imply?

A. The dependency is needed only for unit tests
B. The dependency is needed for compiling and testing, but will be provided by the runtime environment (e.g., Servlet API)
C. The dependency is strictly for the site lifecycle
D. The dependency is always included in the final packaged artifact

25 Which phase comes immediately before package in the default lifecycle?

A. test
B. install
C. compile
D. validate

26 Where should non-Java resources (like application.properties or XML config) be placed in a standard Maven project?

A. src/main/java
B. src/main/resources
C. src/resources
D. src/main/config

27 What 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

28 How can you exclude a specific transitive dependency in the pom.xml?

A. Using the <remove> tag
B. Using the <exclusions> tag within the dependency declaration
C. Using the <ignore> tag
D. Deleting the jar from the local repository

29 What is the Super POM?

A. A POM file that inherits from all other POMs
B. The default parent POM that all Maven projects inherit from implicitly
C. The largest POM file in the project
D. A plugin for managing large projects

30 Which Maven plugin is primarily responsible for running unit tests?

A. maven-surefire-plugin
B. maven-jar-plugin
C. maven-deploy-plugin
D. maven-compiler-plugin

31 Which Maven command is used to generate a project documentation site?

A. mvn doc
B. mvn documentation
C. mvn site
D. mvn report

32 What does the validate phase do?

A. Validates that the project is correct and all necessary information is available
B. Compiles the code
C. Checks if the tests pass
D. Validates the XML syntax of the pom.xml only

33 In a multi-module project, what packaging type must the Parent POM have?

A. war
B. pom
C. jar
D. bundle

34 Which command would you use to run a Maven build in offline mode?

A. mvn -offline package
B. mvn -no-net package
C. mvn -o package
D. mvn --offline package

35 What is the purpose of the deploy phase?

A. To generate the source code
B. To run the application on a local server
C. To copy the final package to the local repository
D. To copy the final package to the remote repository for sharing with other developers and projects

36 The <modules> tag in a pom.xml is used for:

A. Configuring Java modules (Jigsaw)
B. Defining external libraries
C. Listing sub-projects (aggregating) in a multi-module build
D. Defining plugin configurations

37 What is the Effective POM?

A. The result of merging the project's POM with its parent POMs and the Super POM
B. A plugin that optimizes the POM
C. The POM file located in the target directory
D. A POM that has no errors

38 Which directory holds the source code for unit tests?

A. src/tests
B. src/test/java
C. src/main/test
D. test/java

39 If a dependency is defined in <dependencies>, what happens if the version is missing?

A. Maven downloads the release version
B. The build fails, unless the version is managed in <dependencyManagement> of a parent
C. Maven downloads the latest version
D. Maven asks the user for the version

40 What is the Maven command to remove the target directory?

A. mvn remove
B. mvn delete
C. mvn clean
D. mvn erase

41 Which plugin is used to compile Java sources?

A. maven-source-plugin
B. maven-javac-plugin
C. maven-build-plugin
D. maven-compiler-plugin

42 How do you specify the Java version for compilation in the pom.xml?

A. It is automatically detected from the OS
B. Using <java.version> tag in dependencies
C. Using the <jdk> tag
D. Using maven.compiler.source and maven.compiler.target properties

43 What is the result of mvn package for a project with <packaging>war</packaging>?

A. An EAR file
B. A WAR file in the target directory
C. A ZIP file
D. A JAR file

44 Which 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 errors out if duplicate dependencies are found
D. Maven uses the version of the dependency closest to your project in the dependency tree

45 What is the purpose of the settings.xml file in Maven?

A. To write unit tests
B. To define project dependencies
C. To configure the compiler version
D. To configure Maven installation settings, such as proxy servers and local repository location

46 Which scope should be used for a JDBC driver implementation needed only at runtime?

A. test
B. provided
C. runtime
D. compile

47 What is the syntax to execute a specific goal from a plugin directly?

A. mvn plugin-goal
B. mvn -run plugin goal
C. mvn plugin::goal
D. mvn plugin:goal

48 Which command displays the dependency tree of the project?

A. mvn list:dependency
B. mvn show:dependencies
C. mvn dependency:tree
D. mvn tree:list

49 In the pom.xml, the <modelVersion> element usually contains which value?

A. 1.0.0
B. 4.0.0
C. 5.0.0
D. 3.0.0

50 Where does Maven look for the settings.xml file by default?

A. Inside the project folder
B. In the Windows Registry
C. In the Java installation folder
D. In the .m2 directory of the user's home directory