InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
What Is Difference Between Apache Ant And Maven? |
|
Answer» Ant is simply a toolbox whereas Maven is about the application of patterns in ORDER to achieve an infrastructure which displays the characteristics of visibility, reusability, maintainability, and comprehensibility. It is wrong to CONSIDER Maven as a build tool and just a REPLACEMENT for Ant. Ant is simply a toolbox whereas Maven is about the application of patterns in order to achieve an infrastructure which displays the characteristics of visibility, reusability, maintainability, and comprehensibility. It is wrong to consider Maven as a build tool and just a replacement for Ant. |
|
| 2. |
What Is A Mojo? |
|
Answer» A mojo is a Maven plain Old Java Object. Each mojo is an executable GOAL in Maven, and a PLUGIN is a DISTRIBUTION of one or more RELATED mojos. A mojo is a Maven plain Old Java Object. Each mojo is an executable goal in Maven, and a plugin is a distribution of one or more related mojos. |
|
| 3. |
What Does The "you Cannot Have Two Plugin Executions With The Same (or Missing) Elements" Message Mean? |
|
Answer» It MEANS that you have executed a PLUGIN multiple times with the same <id>. Provide each <EXECUTION> with a unique <id> then it WOULD be ok. It means that you have executed a plugin multiple times with the same <id>. Provide each <execution> with a unique <id> then it would be ok. |
|
| 4. |
How To Stop The Propagation Of Plugins To Child Poms? |
|
Answer» SET <INHERITED> to FALSE. set <inherited> to false. |
|
| 5. |
How Can You Run The Clean Plugin Automatically During The Build? |
|
Answer» You can put the CLEAN plugin INSIDE the EXECUTION TAG in pom.xml FILE You can put the clean plugin inside the execution tag in pom.xml file |
|
| 6. |
What Is Dependency Exclusion ? |
|
Answer» Any TRANSITIVE DEPENDENCY can be exclude using "exclusion" element. As example, A depends UPON B and B depends upon C then A can MARK C as excluded. Any transitive dependency can be exclude using "exclusion" element. As example, A depends upon B and B depends upon C then A can mark C as excluded. |
|
| 7. |
What Is The Use Of Optional Dependency? |
|
Answer» Any transitive dependency can be marked as optional using "optional" element. As EXAMPLE, A DEPENDS UPON B and B depends upon C. Now B marked C as optional. Then A will not use C. Any transitive dependency can be marked as optional using "optional" element. As example, A depends upon B and B depends upon C. Now B marked C as optional. Then A will not use C. |
|
| 8. |
What Is A System Dependency? |
|
Answer» Dependency with scope system are always available and are not looked up in repository, they are usually used to TELL MAVEN about DEPENDENCIES which are provided by the JDK or the VM. Thus, system dependencies are especially useful for RESOLVING dependencies on artifacts which are now provided by the JDK. Dependency with scope system are always available and are not looked up in repository, they are usually used to tell Maven about dependencies which are provided by the JDK or the VM. Thus, system dependencies are especially useful for resolving dependencies on artifacts which are now provided by the JDK. |
|
| 10. |
How Can You Build Your Project Offline? |
|
Answer» USE the COMMAND: MVN o PACKAGE. Use the command: mvn o package. |
|
| 11. |
What Are The Benefit Of Storing Jars/external Dependencies In Local Repository Instead Of Remote One? |
|
Answer» It uses less storage, it MAKES checking out project QUICKER, non NEED for versioning JAR FILES. It uses less storage, it makes checking out project quicker, non need for versioning JAR files. |
|
| 12. |
Why Profile Is Used In Maven? |
|
Answer» To GIVE PORTABILITY to projects ( e.g. WINDOWS, LINUX etc). To give portability to projects ( e.g. windows, linux etc). |
|
| 13. |
What Are The Elements In Pom That A Profile Can Modify When Specified In The Pom? |
|
Answer» <repositories>, <pluginRepositories>,<DEPENDENCIES>, <plugins> ,<PROPERTIES>, <modules><REPORTING>,<dependencyManagement>,<distributionManagement> <repositories>, <pluginRepositories>,<dependencies>, <plugins> ,<properties>, <modules><reporting>,<dependencyManagement>,<distributionManagement> |
|
| 14. |
How Profiles Are Specified In Maven? |
|
Answer» PROFILES are SPECIFIED using a SUBSET of the elements available in the POM itself. Profiles are specified using a subset of the elements available in the POM itself. |
|
| 15. |
If You Do Not Define Any Information, Where Does Your Pom Inherits That Information From? |
|
Answer» All POMS inherit from a parent (despite explicitly defined or not). This base POM is known as the SUPER POM, and CONTAINS VALUES INHERITED by default. All POMs inherit from a parent (despite explicitly defined or not). This base POM is known as the Super POM, and contains values inherited by default. |
|
| 16. |
What Is A Project's Fully Qualified Artifact Name? |
|
Answer» <groupId>:<artifactId>:<VERSION> <groupId>:<artifactId>:<version> |
|
| 17. |
What Is The Use Of Execution Element In Pom File? |
|
Answer» The <EXECUTION> element CONTAINS information's required for the execution of a PLUGIN. The <execution> element contains information's required for the execution of a plugin. |
|
| 18. |
What Is The Value For Packaging Element In Pom For A Project That Is Purely Meta-data? |
|
Answer» pom. pom. |
|
| 19. |
What Are The Default Values For Packaging Element? If There Is No Packaging Element Defined? What Is The Default Value For That? |
|
Answer» Some of the VALID PACKAGING VALUES are JAR, war, ear and pom. If no packaging value has been specified, it will default to jar. Some of the valid packaging values are jar, war, ear and pom. If no packaging value has been specified, it will default to jar. |
|
| 20. |
How Do You Reference A Property Defined In Your Pom.xml File? |
|
Answer» To reference a property DEFINED in your pom.xml, the property name uses the names of the XML elements that DEFINE the VALUE, with "pom" being allowed as an alias for the PROJECT (root) element. To reference a property defined in your pom.xml, the property name uses the names of the XML elements that define the value, with "pom" being allowed as an alias for the project (root) element. |
|
| 21. |
What Is The Minimal Set Of Information For Matching A Dependency References Against A Dependencymanagement Section ? |
|
Answer» {groupId,artifactId,TYPE,CLASSIFIER}. {groupId,artifactId,type,classifier}. |
|
| 22. |
What Is Dependency Scope? Name All The Dependency Scope.? |
|
Answer» Dependency SCOPE includes dependencies as per the current stage of the build. Various Dependency Scopes are −
Dependency scope includes dependencies as per the current stage of the build. Various Dependency Scopes are − |
|
| 23. |
How Maven Handles And Determines What Version Of Dependency Will Be Used When Multiple Version Of An Artifact Are Encountered? |
|
Answer» Maven DETERMINES what version of a dependency is to be USED when multiple versions of an ARTIFACT are encountered. If TWO dependency versions are at the same DEPTH in the dependency tree, the first declared dependency will be used. This is called dependency mediation. Maven determines what version of a dependency is to be used when multiple versions of an artifact are encountered. If two dependency versions are at the same depth in the dependency tree, the first declared dependency will be used. This is called dependency mediation. |
|
| 24. |
What Does Dependency Management Mean In The Context Of Transitive Dependency? |
|
Answer» It means to directly SPECIFY the versions of artifacts to be used when they are encountered in transitive DEPENDENCIES. For an example project C can include B as a dependency in its dependencyManagement section and directly control which version of B is to be used when it is EVER REFERENCED. It means to directly specify the versions of artifacts to be used when they are encountered in transitive dependencies. For an example project C can include B as a dependency in its dependencyManagement section and directly control which version of B is to be used when it is ever referenced. |
|
| 25. |
What Is Transitive Dependency In Maven? |
|
Answer» Transitive dependency means to AVOID needing to DISCOVER and specify the LIBRARIES that your own DEPENDENCIES require, and including them automatically. Transitive dependency means to avoid needing to discover and specify the libraries that your own dependencies require, and including them automatically. |
|
| 26. |
What Is Difference Between Snapshot And Version? |
|
Answer» In CASE of Version, if Maven once DOWNLOADED the mentioned version say data-service:1.0, it will never try to download a newer 1.0 AVAILABLE in repository. To download the updated code, data-service version is be UPGRADED to 1.1. In case of Version, if Maven once downloaded the mentioned version say data-service:1.0, it will never try to download a newer 1.0 available in repository. To download the updated code, data-service version is be upgraded to 1.1. |
|
| 27. |
What Is Snapshot In Maven? |
|
Answer» SNAPSHOT is a special version that indicates a current development COPY. Unlike regular versions, Maven checks for a new SNAPSHOT version in a REMOTE repository for every BUILD. SNAPSHOT is a special version that indicates a current development copy. Unlike regular versions, Maven checks for a new SNAPSHOT version in a remote repository for every build. |
|
| 28. |
What Is The Command To Create A New Project Based On An Archetype? |
|
Answer» TYPE the following command: mvn ARCHETYPE:GENERATE Type the following command: mvn archetype:generate |
|
| 29. |
What Is Archetype? |
|
Answer» Archetype is a Maven plugin whose task is to CREATE a PROJECT structure as PER its template. Archetype is a Maven plugin whose task is to create a project structure as per its template. |
|
| 30. |
What Are The Things You Need To Define For Each External Dependency? |
|
Answer» External dependencies (LIBRARY JAR location) can be configured in pom.xml in same way as other dependencies.
External dependencies (library jar location) can be configured in pom.xml in same way as other dependencies. |
|
| 31. |
When Does Maven Use External Dependency Concept? |
|
Answer» MAVEN dependency MANAGEMENT using concept of Maven REPOSITORIES (Local, Central, REMOTE). Suppose dependency is not available in any of remote repositories and central repository; in such scenarios Maven uses concept of External Dependency. Maven dependency management using concept of Maven Repositories (Local, Central, Remote). Suppose dependency is not available in any of remote repositories and central repository; in such scenarios Maven uses concept of External Dependency. |
|
| 32. |
What Are The Types Of Maven Plugins? |
|
Answer» Maven provides following TWO TYPES of Plugins:
Maven provides following two types of Plugins: |
|
| 33. |
Why Are Maven Plugins Used? |
Answer»
Maven Plugins are used to: |
|
| 34. |
What Is The Sequence In Which Maven Searches For Dependency Libraries? |
|
Answer» Following is the search pattern: Step 1 − Search dependency in local repository, if not found, move to step 2 else if found then do the further processing. Step 2 − Search dependency in CENTRAL repository, if not found and remote repository/repositories is/are mentioned then move to step 4 else if found, then it is downloaded to local repository for future reference. Step 3 − If a remote repository has not been mentioned, MAVEN simply stops the processing and throws error (Unable to find dependency). Step 4 − Search dependency in remote repository or repositories, if found then it is downloaded to local repository for future reference otherwise Maven as EXPECTED stop processing and throws error (Unable to find dependency). Following is the search pattern: Step 1 − Search dependency in local repository, if not found, move to step 2 else if found then do the further processing. Step 2 − Search dependency in central repository, if not found and remote repository/repositories is/are mentioned then move to step 4 else if found, then it is downloaded to local repository for future reference. Step 3 − If a remote repository has not been mentioned, Maven simply stops the processing and throws error (Unable to find dependency). Step 4 − Search dependency in remote repository or repositories, if found then it is downloaded to local repository for future reference otherwise Maven as expected stop processing and throws error (Unable to find dependency). |
|
| 35. |
What Is Remote Repository? |
|
Answer» Sometimes, Maven does not find a mentioned dependency in central repository as well then it stops the build process and output error MESSAGE to CONSOLE. To prevent such situation, Maven PROVIDES concept of Remote Repository which is DEVELOPER's own custom repository containing REQUIRED libraries or other project jars. Sometimes, Maven does not find a mentioned dependency in central repository as well then it stops the build process and output error message to console. To prevent such situation, Maven provides concept of Remote Repository which is developer's own custom repository containing required libraries or other project jars. |
|
| 36. |
What Is Central Repository? |
|
Answer» It is repository provided by Maven COMMUNITY. It contains a large number of commonly used libraries. When Maven does not FIND any dependency in LOCAL repository, it starts searching in central repository using following URL: http://repo1.maven.org/maven2/. It is repository provided by Maven community. It contains a large number of commonly used libraries. When Maven does not find any dependency in local repository, it starts searching in central repository using following URL: http://repo1.maven.org/maven2/. |
|
| 38. |
What Is The Default Location For Your Local Repository? |
|
Answer» ~/m2./repository. ~/m2./repository. |
|
| 39. |
What Is Local Repository? |
|
Answer» MAVEN local repository is a FOLDER location on your machine. It gets CREATED when you run any maven command for the first time. Maven local repository keeps your project's all DEPENDENCIES (LIBRARY jars, plugin jars etc). Maven local repository is a folder location on your machine. It gets created when you run any maven command for the first time. Maven local repository keeps your project's all dependencies (library jars, plugin jars etc). |
|
| 40. |
What Types Of Maven Repository? |
|
Answer» MAVEN REPOSITORY are of three TYPES:
Maven repository are of three types: |
|
| 41. |
What Is A Maven Repository? |
|
Answer» A repository is a place i.e. directory where all the project jars, LIBRARY JAR, plugins or any other project specific artifacts are stored and can be used by Maven EASILY. A repository is a place i.e. directory where all the project jars, library jar, plugins or any other project specific artifacts are stored and can be used by Maven easily. |
|
| 42. |
How Can You Activate Profiles? |
|
Answer» A Maven Build PROFILE can be activated in various ways −
A Maven Build Profile can be activated in various ways − |
|
| 43. |
What Are Different Types Of Build Profiles? |
|
Answer» BUILD profiles are of three TYPES :
Build profiles are of three types : |
|
| 44. |
What Is Build Profile? |
|
Answer» A Build PROFILE is a set of configuration values which can be USED to set or OVERRIDE default values of Maven build. USING a build profile, you can customize build for different ENVIRONMENTS such as Production v/s Development environments. A Build profile is a set of configuration values which can be used to set or override default values of Maven build. Using a build profile, you can customize build for different environments such as Production v/s Development environments. |
|
| 45. |
What Phases Does A Site Lifecycle Consist? |
|
Answer» The PHASES in SITE LIFECYCLE are:−
The phases in Site Lifecycle are:− |
|
| 46. |
What Phases Does A Clean Lifecycle Consist? |
|
Answer» The CLEAN LIFECYCLE CONSISTS of the FOLLOWING PHASES:
The clean lifecycle consists of the following phases: |
|
| 47. |
What Would This Command Do Mvn Clean Dependency:copy-dependencies Package? |
|
Answer» This COMMAND will clean the project, copy the DEPENDENCIES and PACKAGE the project (executing all PHASES up to package). This command will clean the project, copy the dependencies and package the project (executing all phases up to package). |
|
| 48. |
What Is A Goal In Maven Terminology? |
|
Answer» A goal represents a specific task which contributes to the BUILDING and managing of a project. It may be bound to ZERO or more build PHASES. A goal not bound to any build phase could be executed OUTSIDE of the build lifecycle by DIRECT invocation. A goal represents a specific task which contributes to the building and managing of a project. It may be bound to zero or more build phases. A goal not bound to any build phase could be executed outside of the build lifecycle by direct invocation. |
|
| 49. |
What Are The Phases Of A Maven Build Lifecycle? |
|
Answer» Following are the phases:−
Following are the phases:− |
|
| 50. |
What Would The Command Mvn Clean Do ? |
|
Answer» This COMMAND removes the TARGET DIRECTORY with all the build data before STARTING the build process. This command removes the target directory with all the build data before starting the build process. |
|