Java - Interview Questions and Answers on Build and Compilation

Q1.  How can I change the default location of the generated jar when I command "mvn package"?

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.

Q2.  Can I use different Java versions for building different Eclipse projects ?

Ans. Yes. We can assign different JRE System libraries by going to 

Java Build Path -> Libraries

Q3.  What technologies have you worked with for build management ?

Ans. Ant and Maven

Q4.  What is the difference between Maven, Ant and Jenkins ?

Ans. Maven and Ant are Build Technologies whereas Jenkins is a continuous integration tool.

Q5.  Have you created any build script yourself ?

Ans. Yes, I have worked on many build scripts in last few years.

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

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

Ans. Remote

Q7.  Which of the following is not a build tool ?

 a. Maven
 b. Ant
 c. Gradle
 d. svn

Ans. svn

Q8.  What is Maven's order of inheritance?

Ans. 1. parent pom
2. project pom
3. settings
4. CLI parameters

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

Ans. run mvn -X

Q10.  What is the difference between compile and install ?

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

Q11.  What is a transitive dependency ? Can we override Transitive Dependency version and If Yes, how ?

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. 

Q12.  What is a cyclic dependency ?

Ans. A has dependency of B, B has dependency of C and C has dependency of A,architecture,technical lead

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.

Q13.  What is Jenkins ?

Ans. It is a continuous integration tool written in Java.

Q14.  What is the difference between Maven, Ant and Jenkins ?

Ans. Maven and Ant are Build Technologies whereas Jenkins is a continuous integration tool.

Q15.  Which SCM tools Jenkins supports ?

Ans.  AccuRev, CVS, Subversion, Git, Mercurial, Perforce, Clearcase and RTC

Q16.  What are the various ways in which build can be scheduled in Jenkins ?

Ans. Builds can be triggered by source code management  commits.
Can be triggered after completion of other builds.
Can be scheduled to run at specified time ( crons )
Manual Build Requests

Q17.  What is the relation between hudson and Jenkins ?

Ans. Hudson was the earlier name and version of current Jenkins. After some issue , the project name was changed from Hudson to Jenkins.