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.
Interview Questions and Answers for 'Maven' - 52 question(s) found - Order By Newest
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
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
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 :
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.
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 :
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 :
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 :
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 :
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 :
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 :
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 :