Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b6u469kis46DspusiL
2.3 KiB
2.3 KiB
experienced-2-3y
Runnable companion for the ankurm.com article Java Interview Questions for 2 to 3 Years Experience (Scenario-Based, with Answers).
Thirty-one scenario questions across core Java, collections and streams, concurrency, Spring Boot, REST, JPA and SQL.
Every question that makes a claim about behaviour has a demo here, and a test that asserts the line the article quotes
and writes it to output/. There is no docs/ folder on purpose: the explanations live in the article.
| Component | Version | Verified against |
|---|---|---|
| JDK | 25.0.5.1+2 (Temurin, LTS) | java -version |
| Spring Boot | 4.2.0 (Spring Framework 7.1.0, Spring Data JPA 4.2.0) | maven-metadata.xml on Maven Central; 4.2.0 was published there on 2026-11-19 |
| Hibernate ORM | 7.4.15.Final | mvn dependency:list |
| H2 | 2.5.252 | mvn dependency:list |
| JUnit | 6.1.3 | mvn dependency:list |
| Maven | 3.9.11 | mvn -version |
export JAVA_HOME=/path/to/jdk-25 && export PATH="$JAVA_HOME/bin:$PATH"
cd experienced-2-3y
mvn test # 7 tests (3 plain Java, 4 Spring); rewrites output/01-07
./scripts/run-all.sh # also regenerates output/08 (javac's own error for src/broken/)
| Where | Questions | Transcript |
|---|---|---|
core/CoreQa |
1-6 core Java | output/01-core-java.txt |
coll/CollectionsQa |
7-12 collections, streams, Optional | output/02-collections-streams.txt |
conc/ConcurrencyQa |
13-17 concurrency | output/03-concurrency.txt |
spring/ (Invoice, Counters, TxProbe, Transfers) + SpringCoreScenariosTest |
18-21 Spring | output/04-spring-di-tx.txt |
spring/ (CustomerApi, ApiErrors) + RestScenariosTest |
22-24 REST | output/06-rest.txt |
spring/ (Customer, CustomerOrder, OrderReports) + JpaScenariosTest |
25-27 JPA | output/05-jpa.txt |
SqlScenariosTest |
28-31 SQL | output/07-sql.txt |
src/broken/NonExhaustiveSwitch.java |
6 (compile error) | output/08-compile-errors.txt |
03-concurrency.txt comes from deliberately racy code: the tests assert that updates were lost, but the exact
numbers differ on every run, so the article treats them as indicative. src/broken/ is excluded from the Maven build.