INTERVIEW PREP
Interview questions
570 questions from real DevOps, SRE, platform engineering and MLOps interviews, with the answer an interviewer wants to hear. Try answering out loud first, then open the model answer.
Showing 1–15 of 20 questions
Learn Maven & Build Tools →1.What happens when you run mvn package?Beginner
Maven runs every lifecycle phase up to package in order: validate, compile, test, then package. Each phase runs the plugin goals bound to it, producing the jar in target/.
2.What are dependency scopes?Beginner
compile (default, everywhere), provided (compile only, the runtime supplies it), runtime (not for compiling), test (tests only), and system/import. Scope controls the classpath and whether the dependency is packaged.
3.What is a POM file?Beginner
pom.xml describes a Maven project: its coordinates (groupId, artifactId, version), dependencies, plugins, packaging and build settings. Maven reads it to know what to download and how to build.
4.What are Maven coordinates?Beginner
groupId:artifactId:version (plus packaging and classifier) uniquely names an artifact, for example org.springframework:spring-core:6.1.2. Repositories store artifacts by these coordinates.
5.What are the main phases of the Maven lifecycle?Beginner
validate, compile, test, package, verify, install and deploy. Running a phase runs every phase before it, so mvn install also compiles, tests and packages.
6.What is the difference between mvn install and mvn deploy?Beginner
install copies the built artifact into your local repository (~/.m2) so other local projects can use it. deploy uploads it to a remote repository like Artifactory or Nexus for everyone.
7.Two libraries need different versions of the same dependency. What does Maven do?Mid
Nearest definition wins in the dependency tree; at equal depth, the first declared wins. Use mvn dependency:tree -Dverbose to see conflicts and pin the version in dependencyManagement.
8.What is a SNAPSHOT version?Mid
A version still in development, like 1.2.0-SNAPSHOT. Repositories store timestamped builds and Maven checks for newer ones. Releases must never depend on snapshots.
9.How do you speed up Maven builds in CI?Mid
Cache ~/.m2, use a repository manager mirror, build in parallel with -T, build only changed modules with -pl/-am, skip unneeded plugins, and consider the build cache extension or mvnd.
10.What is dependencyManagement used for?Mid
It fixes versions of dependencies in one place (often a parent POM or a BOM) without adding them to every module. Modules then declare the dependency without a version and get the managed one.
11.How do you see why a dependency is on the classpath?Mid
mvn dependency:tree shows the full tree, and -Dincludes=group:artifact filters it. Use <exclusions> or dependencyManagement to fix unwanted versions.
12.What is a multi-module project, and why use one?Mid
A parent POM lists modules that build together in the right order (the reactor). It shares versions and plugins and lets you build only what changed with -pl module -am.
13.What are Maven profiles?Mid
Named sets of settings switched on with -P name, a property, the OS or a missing file. Use them sparingly, for example for a release or integration-test build, so builds stay predictable.
14.What is the difference between the Surefire and Failsafe plugins?Mid
Surefire runs unit tests in the test phase and fails the build right away. Failsafe runs integration tests in integration-test and checks results in verify, so cleanup in post-integration-test still runs.
15.How do you make builds reproducible?Senior
Pin all plugin versions, set project.build.outputTimestamp, use the Maven Wrapper for the Maven version, enforce Java and Maven versions with the enforcer plugin, and verify with artifact:compare.