Maven Skill Test Linkedin Question Answers
1. ___ contains
information about the project and various configuration detail used by Maven to
build the project(s).
- OOPS
- Both A and B
- POM
- None of the above
2. Which of the following command removes the target directory with all
the build data before starting the build process?
- mvn clean
- mvn build
- mvn compiled
- mvn site
3. What is an archetype in maven?
- pckage for maven librairies
- configuration file
- A template for any type of Java project
- source packagea
4. Which of the following is not a dependency scope in Maven?
- System
- Export
- Compile
- Test
5. Below is a section of a settings.xml file. How can you use the path to
the app home in your POM file?
<profiles>
<profile>
<id>set=app-home</id>
<properties>maven-people-plugin</artifactId>
<application-home>/path/to/application</application-home>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>set-app-home</activeProfile>
</activeProfiles>
- ${activeProfile}
- ${set-app-home}
- ${application-home}
- ${/path/to/application}
6. Which one of the following is a naming scheme in
which the implicit name for a mock object is the mocked type’s name prepend
with “mock”.
- RetroNamingScheme
- CamelCaseNamingScheme
- JavaReflectionImposteriser
- LastWordNamingScheme
7. What is the sequence in which maven looks for the
resources?
- Remote-> Local -> Maven Central
- Local -> Remote - Maven Central
- Remote-> Maven Central - > Local
- None of the above
7. Why is it best practice to avoid overriding the default directory
structure?
- Keeping the default structure reduces onboarding time, because developers recognize it.
- Overriding the default structure is very complex.
- Overriding the default structure will cause Maven to take longer to compile your code.
- all of these answers
8. What is the default value of the warSourceDirectory configuration
property of the Maven WAR Plugin?
- /src/main/webapp
- /src/web
- /src/main/war
- /src/main/WEB-INF
9. How do you check for unused dependencies in your project?
- Run mvn clean and look at which plugins are not mentioned in the output.
- You will need to do this manually.
- Include the Maven dependency plugin in your POM file and run the unpack goal.
- Run the analyze goal of the dependency plugin.
10. Which of the following is not type of Maven
Repository?
- local
- dependency
- remote
- central
11. How many times is compiler:compile called when executing mvn clean
compile test package?
- one
- two
- none
- three
12. A compile-time dependency of a dependency for your project is often
called a_ dependency.
- runtime
- Transitive
- provided
- test
13. When building a Maven Archetype, where do you put your prototype
files?
- src/main/template
- src/main/archetype
- src/main/resources/archetype-resources
- src/main/java
14. What element in the pom.xml file allows you to provide values that can
be reused in other elements of the pom.xml?
- Plugins
- Build
- Properties
- Parent
15. In a multimodule project, if you have a plugin bound to a phase in the
parent, it will be bound to the same phase in the module. What strategy could
you employ to prevent the plugin from executing in the module?
- In the excluded element of the build section of the POM, list the plugin you do not want to run.
- Set the phase in the module to none.
- Set a value in the configuration of the plugin in the module to be excluded like this: TRUE.
- Do not specify the plugin in the module.
16. Bellow is a definition of the Maven JAR Plugin, where the main class
is set to com.palmer.bethan.App. What is the effect of this?
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.palmer.bethan.App</mainClass>
</manifest>
</archive>
</configuration>
- Maven will generate javadocs for the App class.
- Maven will include only the App class when it compiles the source code.
- Maven will generate an executable JAR, which can be used to run the App class.
- Maven will add an empty main method to the App class.
17. ------------- is a naming scheme in which the implicit name for a mock
object is the mocked type's name prepend with "mock?
- RetroNamingScheme
- CamelCaseNamingScheme
- JavaReflectionImposteriser
- LastWordNamingScheme
18. Which command is used to run the clean lifecyle followed by verify, install, and package with Maven?
- mvn clean
- mvn verify
- mvn package
- mvn install
19. How do you skip the tests when running a mvn package command?
- Use -Dtest=skip
- Use -DskipTests=true
- Use -Dtests=pass
- Use a plugin that can be configured to skip tests
20. What is one of the advantages of using properties in Maven?
- Properties provide a template for you to build Maven projects with a certain structure.
- Properties allow you to inherit values from the parent POM in the child POM.
- You can avoid hard-coding values in multiple places.
- Properties speed up your Maven build.
21. If you wish to build and package your artifact using the Maven package
goal but don't want to execute the unit tests, which environment variable and
value would you use?
- maven.test.ignore=TRUE
- maven.test.run=FALSE
- maven.test.skip=TRUE
- maven.verify.execute=FALSE
22. For what purpose can plugins use the validate phase in the default
lifecycle?
- to check the parent POM file defines all of the child POM files
- to carry out checks before building the project
- to ensure plugins defined in the POM file are in the correct order
- to check the project structure is correct after building a project
23. When building a Maven EAR project and specifying the configuration of
which projects to include, what is the element in the plugin configuration that
contains Enterprise Java Bean projects?
- modules/webModule
- modules/ejbModule
- modules/enterpriseModules
- modules/services
24. What is the main purpose of the install phase?
- to compile the source code of the project
- to install all of the remote dependencies
- to deploy the final project artifacts into a remote Maven repository
- to copy the final project artifacts into the local Maven repository
25. What are the phases of the clean lifecycle?
- pre-clean,clean and post-clean
- Compile, clean and install
- clean and install
- validate, clean and deploy
26. What is the default scope for Maven dependencies?
- Test
- Compile
- Runtime
- Build
27. Which build plugin allows you to create a "fat" JAR file
that contains all of the dependencies in the final JAR file?
- Fatjar
- Shade
- Dependency
- Package
28. The settings.xml file that provides the user-specific settings for
Maven is contained in which directory by default?
- ${maven.home}/${user.name}/settings.xml
- ${user.home}/.m2/settings.xml
- ${maven.home}/conf/settings.xml
- ${user.home}/maven/settings.xml
29. Suppose you are using Maven in a corporate environment and, to save
bandwidth, you want to prevent the need for large numbers of developers to
download the same dependency from the internet. What do you do to limit this?
- Create an internal corporate repository to store copies of the necessary artifacts.
- It is not possible to do this.
- When defining the dependency, set the scope to provided.
- Each developer should define the dependency in the POM file in the local copy of the project.
30. Suppose you are packaging a Maven project and see the following error:
“[WARNING] Using platform encoding (Cp1252 actually) to copy filtered
resources, i.e. build is platform dependent!” What do you add to your POM file
to set the platform encoding to ensure your build is not platform dependent?
- <project.build.sourceEncoding>
- <project.build.resources>
- <maven.compiler.source>
- <project.compiler.encoding>
31. If you want to utilize a locally develop JAR file in another project
and that JAR file has not been deployed to either the Maven central repository
or your own locally sourced mirror repository, what Maven goal do you need to
execute on the locally developed JAR project?
- test
- install
- compile
- package
33. What does it mean if the scope of a dependency is runtime?
- The dependency is not required to compile the project, but is needed at runtime.
- The dependency is needed at compile time and at runtime, and must be packaged for distribution.
- The dependency is needed at compile time and at runtime, but does NOT need to be packaged for distribution.
- The dependency is required for compilation.
34. If you want to utilitze a locally developed JAR file in another
project and that JAR file has not been deployed to either the Maven central
repository or your own locally sourced mirror repository, what Maven goal do
you need to execute on the locally developed JAR project?
- package
- install
- compile
- test
35. Why might you not want to include groupId and version elements in
child POM files?
- If you include these elements, an error will be thrown when you try to build the project.
- These elements are inherited from the parent POM file, and do not need to be repeated.
- Child POM files should include definitions of only dependencies and plugins.
- The values in the parent POM will be overridden by what is defined in the child POM.
36. In multimodule projects, what do child POMs inherit from the parent
POM?
- all of these answers
- dependencies
- groupId
- version
37. Which structure in a settings.xml file allows for flexing properties
based on some value for the runtime of Maven?
- Environment
- Properties
- Switch
- Profiles
38. What is the default packaging type for a Maven project build artifact?
- WAR
- JAR
- EAR
- POM
39. -------------- interface defines a sequence of expectations.
- Sequence
- States.
- Expectations
- Mockery
40. When performing a release using the Maven release plugin, which
environment variable for batch mode is used to define the stamp placed in SCM
to indicate the state of the artifact for the actual release?
- tag
- scmMark
- developmentVersion
- releaseVersion
41. These are two general uses of plugins. The first is build and the
second is _
- servers
- dependencies
- reporting
- distribution management
42. What does the mvn clean command do?
- It updates the version of the plugins defined in the POM file.
- It removes the target directory
- It removes unused dependencies in your project
- It builds your project
43. What argument do you pass to Maven in order to update SNAPSHOT from the
remote repository?
- -U
- -J
- -X
- -S
45. Many organizations set up local mirrors to the Maven central
repository. In order to leverage your company's Maven repository as a proxy for
the Maven central repository, which element should you put into the
settings.xml file?
- Replacements
- Proxies
- Mirrors
- LocalRepositories
46. How can Maven profiles be triggered?
- through Maven settings
- by explicitly calling the profiles using the -P flag
- based on environment variables
- all of these answers
47. Suppose you want to include a properties file in the JAR generated by
your Maven build. What directory should you put it in?
- ${basedir}/src/main/java/resources
- ${basedir}/resources
- ${basedir}/src/main/resources
- ${basedir}/src/main/properties
48. What will the mvn dependency:tree command do?
- Verify the dependencies defined in the POM file.
- Print out a report of your project's dependencies in a tree format.
- Download all the transitive dependencies.
- Prune unused dependencies from your dependency tree.
49. What environment variable can you alter to increase the memory Maven
uses?
- MAVEN_OPTS
- M2_HOME
- MAVEN_MEMORY
- PATH
50. Which Maven plugin would you leverage to specify the version of the
compiler to target as well as the source level of the language?
- Compiler
- Versions
- Surefire
- Target
51. What is a valid packaging type for a Maven project?
- POM
- EAR
- WAR
- all of these answers
52. When performing a build, which Maven plugin will allow you to set the
specific version of the artifact to be built without manual modifying the
pom.xml file?
- Versions
- Compiler
- Surefire
- Javadoc
53. Which goal would you use with the Dependency plugin to determine which
included dependencies are not used, as well as those you are using that you
have not defined?
- dependency:tree
- dependency:evaluate
- dependency:analyze
- dependency:properties
54. What does the mvn -version command do?
- it builds your Maven project.
- It print out your installed version of Maven.
- It installs Maven on your computer.
- It updates Maven to the latest version.
55. What directory structure contains the source code of your artifact?
- src/code
- src/test/java
- src/main/java
- src/main/resources
56. There are several properties available for use in a pom.xml file that
refer to details of the project, such as groupId and version. What do all of
these properties start with?
- pom
- maven
- jar
- project
57. The goal that is executed to generate and deploy a documentation
website is _.
- deliver
- doc
- site
- deploy
58. When building a Maven Archetype, what is the filepath and file of the
archetype descriptor that specifies how to lay out the prototype files?
- src/main/resources/META-INF/maven/archetype-descriptor.xml
- src/main/template/descriptor.xml
- src/main/archetype/descriptor.xml
- src/main/resources/META-INF/maven/maven-archetype.xml
59. When two dependencies of your Maven project introduce the same
transitive dependency with different versions, which one(s) will be included in
the dependency list for your project?
- the dependency with the higher version
- the transitive dependency version of the artifact that is closest to your project
- the transitive dependency that comes from the dependency listed first in the pom.xml file
- the transitive dependency that comes from the dependency listed last in the pom.xml file
60. If your machine is behind a proxy, where should you specify the proxy
server settings in order for Maven to access remote resources?
- .m2/proxy.txt
- settings.xml
- pom.xml
- proxy.xml
61. How can you use Maven to run unit tests in parallel?
- Specify the Maven Surefire Plugin and add a configuration that sets the parallel element to true.
- It is not possible to do this.
- Implement the JUnit dependency and add a configuration that sets the parallel element to true.
- Move each test suite into a separate submodule.
62. When building a web application with a WAR type project, which project
directory should contain the style sheet, JavaScript, and other static file?
- src/main/static
- src/main/webapp
- src/main/web
- src/main/resources
63. How do you run a single unit test in Maven?
- Use the -Dtest= flag and pass in the name of the test.
- Maven runs only a single unit test by default.
- Use a plugin that can specify the test you want to run.
- It is not possible to do this.
64. What does the following command do?
>
mvn archetype:generate \
-DgroupID=sample-maven-project
\
-DartifactID=com.palmer.bethan.sample
\
-Dversion=1.0.0
\
-DinteractiveMode=false
- It does nothing since no archetype has been specified
- It generates a new Maven archetype
- It cleans and installs the sample-maven-project project
- It generates a new Maven project using the default Maven archetype
65. ___ contains information about the project and various configuration
detail used by Maven to build the project(s).
- POM
- OOPS
- Both Above
- None of the above
66. Why will an mvn install command not deploy any artifacts to a remote
repository?
- Deploying artifacts to a remote repository must be done manually.
- The deploy phase of the default Maven lifecycle comes after the install phase.
- The name of the artifact must also be specified in the command.
- The name of the remote repository must also be specified in the command.
67. ___________ method performs an action in response to an invocation.
- perform(String script)
- where(String name, Object value)
- describeTo(Description description)
- invoke(Invocation invocation)