Interview Questions and Answers for 'Maven' | Search Interview Question - javasearch.buggybread.com
Javasearch.buggybread.com

Search Interview Questions


 More than 3000 questions in repository.
 There are more than 900 unanswered questions.
Click here and help us by providing the answer.
 Have a video suggestion.
Click Correct / Improve and please let us know.
Label / Company      Label / Company / Text

   



Interview Questions and Answers for 'Maven' - 52 question(s) found - Order By Newest

next 30
Very frequently asked. Among first few questions in almost all interviews. Among Top 5 frequently asked questions. Frequently asked in Indian service companies (HCL,TCS,Infosys,Capgemini etc based on multiple feedback ) and Epam Systems
  Q1. Difference between == and .equals() ?Core Java
Ans. "equals" is the method of object class which is supposed to be overridden to check object equality, whereas "==" operator evaluate to see if the object handlers on the left and right are pointing to the same object in memory.

x.equals(y) means the references x and y are holding objects that are equal. x==y means that the references x and y have same object.

Sample code:

String x = new String("str");
String y = new String("str");

System.out.println(x == y); // prints false
System.out.println(x.equals(y)); // prints true

  Sample Code for equals

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   string comparison   string   object class   ==    equals   object equality  operator   == vs equals   equals vs ==     Asked in 294 Companies      basic        frequent

Try 6 Question(s) Test


 Q2. What is a transitive dependency ? Can we override Transitive Dependency version and If Yes, how ?Maven
Ans. Transitive dependency is the dependencies not defined directly in the current POM but the POM of the dependent projects.

Yes we can override transitive dependency version by specifying the dependency in the current POM.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     maven   maven dependencies   maven transitive dependency   technical lead   build management


Usually asked to experienced developers.
 Q3. What is a cyclic dependency ?Maven
Ans. A has dependency of B, B has dependency of C and C has dependency of A

With Maven 2 , came transitive dependency wherein in above scenario, C will acts as a dependency of A as if this dependency has been defined directly in A but the negative side is that if it leads to cyclic dependency , it creates problems.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     maven   dependencies   cyclic dependencies   transitive dependencies   build management     Asked in 1 Companies        frequent


 Q4. Which of the following is dependency exclusion ?

a. A doesn't depend on C and then A marks C as excluded.
b. A Depends on B and B depends on C and then A can mark B as excluded.
c. A and B depends on C and then they can mark C as excluded.
d. A depends upon B and B depends upon C then A marks C as excluded.
Maven
Ans. A depends upon B and B depends upon C then A marks C as excluded.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     maven   dependency exclusion


 Q5. How do you resolve Maven Dependencies issue while upgrading dependencies versions ?Maven
Ans. Step 1 - Upgrade the required dependency , perform build and check build errors

Step 2.1 - If the error is of missing transitive dependency ( which is rare and means that the previous version has a dependency which is missing in the later version ), I would look for the dependency in google and hence will include it as direct dependency in Pom file.

Step 2.2. If the error is for Duplicate dependencies , and the choice is between transitive and direct dependency, I usually remove the direct dependency.

Step 2.3 - If the error is for Duplicate dependencies , and both are transitive dependencies. I first make a choice ( usually later version ) and then ignore the previous version dependency.

Step 2.4 - If the error is for Duplicate dependencies , and there are more than 2 duplicates, I usually ignore it by specifying within maven-enforcer-plugin config.

Step 3 - Perform a Clean Build.

Step 4 - Check Maven Dependency Tree to make sure that Duplicates have been removed or dependency is there in case of missing dependency.

Step 5 - Perform tests and make sure that there are no runtime problems.

Step 6 - If there are runtime problems ( which very likely occurs if you have different version dependencies , very likely by doing 2.4 , you will have to remove step 2.4 and alternately perform 2.2 or 2.3 )

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     maven  maven dependency  transitive dependency


 Q6. What is Maven's order of inheritance?Maven
Ans. 1. parent pom
2. project pom
3. settings
4. CLI parameters

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     maven   build technologies   pom.xml   parent pom   project pom   build management

Try 1 Question(s) Test


 Q7. What is a Mojo?Maven
Ans. 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.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     maven   build technologies   mojo


  Q8. Write a Program to check if 2 strings are Anagrams ?Core Java
Ans. public void checkIfAnagram(String str1,String str2){
boolean anagram = true;
for(char c:str1.toCharArray()){
if(!str2.contains(String.valueOf(c))){
System.out.println("Strings are Anagrams");
anagram = false;
}

if(anagram == true){
System.out.println("Strings are not Anagrams");
}
}
}

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve      check if 2 strings are Anagrams     Asked in 30 Companies      basic        frequent


 Q9. Where do we configure repositories in Maven ?Maven
Ans. Within settings.xml in either MAVEN_HOME or .M2 directory.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     maven   maven repository


 Q10. What are different type of repositories in Maven ?Maven
Ans. Local and Remote.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     maven   maven repository


 Q11. How does Maven looks for a resource ? Maven
Ans. It refers to the settings.xml to look for the repositories to look for the resource. First It looks into the configured local repository, then it looks into the configured Remote repositories. If the resource is still not found , it looks it within maven repository central i.e repo1.maven.org. If its still not found, it throws the exception saying "Unable to find resource in repository central".

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     maven   maven repository


 Q12. What is repository central ?Maven
Ans. Its the repository provided by Maven. In case your POM specify the dependencies and its not available in the configured local and the remote repository. It then looks for the resource in Maven Central. Maven provides most of the generic dependency resources at this remote location.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     maven   maven repository


 Q13. What is Maven's order of inheritance?

a. parent pom -> project pom -> settings -> CLI parameters
b. project pom -> parent pom -> settings -> CLI parameters
c. settings -> parent pom -> project pom -> CLI parameters
d. CLI parameters -> settings -> parent pom -> project pom
Maven
Ans. parent pom -> project pom -> settings -> CLI parameters

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     maven

Try 1 Question(s) Test


 Q14. Which of the following is not a dependency scope in Maven ?

a. Compile
b. Test
c. System
d. Export
Maven
Ans. Export

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     maven   maven dependencies


 Q15. What is the best practice configuration usage for files - pom.xml or settings.xml ?Maven
Ans. The best practice guideline between settings.xml and pom.xml is that configurations in settings.xml must be specific to the current user and that pom.xml configurations are specific to the project.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     maven   build technologies   pom.xml   settings.xml   architecture   technical architect   technical lead   build management   build and release

Try 1 Question(s) Test


 Q16. How can I change the default location of the generated jar when I command "mvn package"?Maven
Ans. By default, the location of the generated jar is in ${project.build.directory} or in your target directory. We can change this by configuring the outputDirectory of maven-jar-plugin.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     maven   build technologies   build management   build and release   release management


 Q17. How do I determine which POM contains missing transitive dependency?Maven
Ans. run mvn -X

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     maven   build technologies   pom   build management


 Q18. What would you do if you have to add a jar to the project using Maven ?Maven
Ans. If its already there in Maven local repository, We can add that as a dependency in the project pom file with its Group Id, Artifact Id and version.

We can provide additional attribute SystemPath if its unable to locate the jar in the local repository.

If its not there in the local repository, we can install it first in the local repository and then can add it as dependency.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     maven   maven dependencies   jar   architecture


 Q19. Have you ever had problem getting your projects in eclipse refreshed after you made changes in the Pom files ?Maven
Ans. Yes, It happens many times but I would usually perform mvn eclipse:eclipse and this would resolve the project refresh problems.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     maven   maven repository   eclipse     Asked in 1 Companies


 Q20. What is the difference between compile and install ?Maven
Ans. Compile compiles the source code of the project

whereas

Install installs the package into the local repository, for use as a dependency in other projects locally

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     maven   install   build management


 Q21. How to perform a clean install without executing Tests ?Maven
Ans. mvn clean install -Dmaven.test.skip=true

or

mvn install -DskipTests

or


org.apache.maven.plugins
maven-surefire-plugin

true



within parent POM file.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     maven   maven install   unit testing   unit tests


 Q22. How can we see Dependencies for the project and where exactly they are defined ?Maven
Ans. Using

mvn dependency:tree

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     maven   maven repository   maven dependencies   dependency tree


 Q23. What are the benefits of transitive depency in Maven ?Maven
Ans. Transitive dependencies allows to avoid specifying the libraries that are required by the project which are specified in other dependent projects - Remote or Local.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     maven   maven repository   dependencies   transitive dependencies   build management


 Q24. What is the difference between Maven, Ant and Jenkins ?Tool
Ans. Maven and Ant are Build Technologies whereas Jenkins is a continuous integration tool.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     maven   ant   jenkins   build technologies


 Q25. How do I determine which POM contains missing transitive dependency?

a. mvn -A
b. mvn -M
c. mvn -R
d. mvn -X
Maven
Ans. mvn -X

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     maven   maven transitive dependencies


 Q26. What is the sequence in which Maven looks for the resources ?

a. Remote-> Maven Central - > Local
b. Local -> Remote - Maven Central
c. Remote-> Local -> Maven Central
d. Maven Central -> Local -> Remote
Maven
Ans. Local -> Remote - Maven Central

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     maven


 Q27. POM stands for ...

a. Project Object Model
b. Project Oriented Model
c. Prospective Object Model
d. Prospective Objective Model
Maven
Ans. Project Object Model

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     maven   pom

Try 1 Question(s) Test


 Q28. Which of the following is not type of Maven Repository ?

a. Local
b. Remote
c. Maven Central
d. Maven Local
Maven
Ans. Maven Local

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     maven   repositories


 Q29. What is the default location of local repository ?

a. ~/.m2/repo
b. ~/m2./home/repository
c. ~/m2./repository
d. ~/m2./home/repo
Maven
Ans. ~/m2./repository

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     maven   repositories   local repositories   m2


 Q30. Which of the following is not type of Maven Plugin ?

a. Build
b. Reporting
c. Remote
d. All are valid Maven Plugin types
Maven
Ans. Remote

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     maven   maven plugins


next 30

Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked: